another question:
when I create a window, I use function CALLBACK WndProc(), if another dialog box will be triggered by clicking a certain button in this window, I may use another function CALLBACK DlgProc(). if there is other more, I may use another CALLBACK DlgProc()....
could I integrate all those DlgProc() or ToolDlgProc() or other functions in WndProc()? then it may looks more simple.
I mean, all those functions looked the same:
like

LRESULT CALLBACK WndProc(....)
{ 
 switch(msg)
 { 
  case WM_COMMAND:....
         case  .....
        }
}
BOOL CALLBACK DlgProc(....)
{
    switch(Message)
    {
        case WM_INITDIALOG:
        case ...
     }
}

You could do it all in just one callback function, but it might sometimes get a little messy and complicated because the function might have to decide which window it was being called for. Yes, the window handle is passed to the callback function, but that might not be enough to distinguish between dialogs or controls.

The macros CALLBACK and WINAPI should be used because (1) they are Microsoft standards and (2) if Microsoft decides to change the macros then you will be SOL if you didn't use them. The same with using int instead of HANDLE -- 64-bit programmers will find out very quickly when they begin to migrate their 32-bit windows programs to 64 bit if they did not use standard Microsoft macros because the size of the HANDLE object was changed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.