how can call the message loop in a diferent way?

windows program is like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//Message Loop
WPARAM MessageLoop()
{
    MSG msgEvents;
    while(GetMessage(&msgEvents,NULL,0,0))
    {

        if(!IsDialogMessage(ActivatedForm,&msgEvents))
        {
            TranslateMessage(&msgEvents);
            DispatchMessage(&msgEvents);
        }
    }
    return msgEvents.wParam;
}


int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPreviousInstance, LPSTR lpCmLine, int nCmdShow)
{
    //do some stuff...
    return MessageLoop();
}

i had tryied called the MessageLoop() on a diferent place without sucess :(
(i have a form class that creates a window and i have, inside the class, a window procedure)
can i call the MessageLoop(), when i create the form\window?
What exactly is the problem? Does it just not bring up a window? Does it freeze? Do you get a segfault?

Your message loop is fine, you can pump messages from anywhere on the same thread that you create the window.
sorry. but the email notification was off on these thread :(
freezes until the MessageLoop() it's called, because theres to many code before it :(
that's why i need some advice :(
in my opinion: the best is call the MessageLoop(), after the 1st form is created. but i didn't get sucess for it :(
because i need return a value, or the application can close.
on "//do some stuff..." i have several code. while is doing\executing that code, the application is freezed. after that the MessageLoop() give me back the application.
what you can tell me more?

can i call the MessageLoop(), when i create the form\window?


Without further information I'd say you would have to be very careful about what you mean by "//do some stuff..."

Don't forget that some of that "stuff" could possibly require a running message pump, which you haven't yet provided, apparently, if you havn't called MessageLoop() yet.
you have right freddie.
so what i did:
- instead add all code on main function, i just changed the variables events;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPreviousInstance, LPSTR lpCmLine, int nCmdShow)
{
    property<variant> prtVariant;
    prtVariant=100;
    variant intnumber;
    variant intNumbere="hello world";
    variant *intNumbere1=&intNumbere;
    *intNumbere1="joaquim";
    string intnumber2;
    variant intnumber3;

    cw.Create=[&]()
    {
        cw.SetTextBackColor(RGB(0,0,255), RGB(0,255,0));
        cw.write(*intNumbere1);
        cw.write("\nhello world","\n","enter the 1st name: ",1000, "\n");
        cw.read(intnumber);
        cw.write("enter the 2nd name: ");


        cw.read(intnumber2);
        cw.write("enter the age: ");
        cw.read(intnumber3);
    };

    fb.Create=[&]()
    {
        img.Backcolor=RGB(255,0,0);
        img.Backcolor=-1;
        usrName.adress="viseu hello";

        usrName.age=23;
        usrName.name="joaquim";
        usrName.foto.FileName="C:\\Nova pasta\\007.gif";


        //SaveDataBase("C:\\Nova pasta\\username1.dat",usrName);
        //ReadDataBase("C:\\Nova pasta\\username1.dat",usrName2);

        fb.Paint=[](HDC windowdc)//fb is my form object
        {
            img2.draw(windowdc);

        };

        img2=img;

        img.Backcolor=GetSysColor(COLOR_MENU);
        img.Backcolor=Transparent;
        fb.BackColor=RGB(255,0,0);
        mnuExit.imgMenu=img2;
        mnuExitSys.imgMenu=img2;
        mnuExitSys2.imgMenu=img2;
        mnuLOL.imgMenu=mnuExitSys2.imgMenu;
        mnuFile.imgMenu=img2;

        mnuLOL.Click=[&]()
        {
            mnuLOL.Check=!mnuLOL.Check;
            MessageBox("clicked!!!");
        };

        mnuLOL.MouseEnter=[&]()
        {
            mnuLOL.Caption="hello";
        };


        mnuLOL.MouseLeave=[&]()
        {
            mnuLOL.Caption="good bye";
        };

        mnuExit.MouseEnter=[&]()
        {
            mnuExit.Caption="hi";
        };

        mnuExit.MouseLeave=[&]()
        {
            mnuExit.Caption="by";
        };
        img2.DrawImage=[&](int subimage)
        {
            if(fb.Visible==true)
                fb.Refresh();




        };
        imgIcon.DrawImage=[&](int subimage)
        {
            fb.SetIcon(imgIcon);
        };


        //fb.SetIcon("c:\\Users\\Cambalinho\\Documents\\CodeBlocks\\classcontrols\\x-7.ico");

        //tmr.Start();
        mnuExitSys2.Click=[&]()
        {
            MessageBox("hello dear friend");
        };
        mnuExitSys.MouseEnter=[]()
        {
            mnuExitSys.Caption="hello dear friend";
        };
        mnuExitSys.MouseLeave=[]()
        {
            mnuExitSys.Caption="bye dear friend";
        };
        mnuExitSys2.MouseEnter=[]()
        {
            mnuExitSys2.imgMenu.DrawImage=[](int subimage)
            {
                mnuExitSys2.imgMenu.Selection(RGB(255,0,0));
            };
            mnuExitSys.Caption="hey";
        };

        mnuExitSys2.MouseLeave=[]()
        {
            mnuExitSys2.imgMenu.DrawImage=[](int subimage)
            {
                 mnuExitSys2.imgMenu.Selection(RGB(0,255,0));
            };
            mnuExitSys.Caption="bye";
        };

        mnuExit.Click=[]()//clique do rato num butao
        {
            mnuExit.Check=!mnuExit.Check;
        };

        btnHorizontal.setLeft(4000);
        btnHorizontal.setTop(4000);
        btnHorizontal.MouseClick=[]()
        {
            MessageBox("hello world!!!");

            lblTest.text="hello brother";
        };

        int i=0;
        for (i; i<8; i++)
        {
            int inttop=150 + (i*50);

            btnarray[i].setTop(inttop);
            btnarray[i].setLeft(0);
            btnarray[i].setText(to_string(i));
            btnarray[i].MouseClick=[i]()
            {
                MessageBox(btnarray[i].getText(), "");
                MessageBox(vrttest);
                vrttest=lblTest.width;
            };
        }

        btnarray[0].MouseClick=[&]()
        {
            //MessageBox(btnHorizontal[8].getText());
            fb.setAutoScroll(true);
            static int i=0;
            CreateDMI(frmmdi,"hello world " + to_string(i));
            MessageBox(intnumber);
            MessageBox(intnumber2);
            MessageBox(intnumber3);
            i++;
        };

        btnarray[1].MouseClick=[&]()
        {
            fb.print();
        };

        cw.Create();//take several time
    };



    return MessageLoop();

}

Create it's an event(just a function variable name).
now i see 1 problem on:
cw.Create();//take several time
- you have 1 question why i called cw Create there, if it's called on window console form?
- that's because i'm getting trouble on it :( ;
- it's cake several time for execute the code.

so let me ask you 1 diferent thing, from these problem, when i create a RichText control, i must change the create message. but i'm getting problem for catch it's message. can anyone advice me?

Topic archived. No new replies allowed.