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:

  case WM_COMMAND:....
         case  .....
        case WM_INITDIALOG:
        case ...

Recommended Answers

Some more info can be found here:

Namely, it says that WINAPI and CALLBACK are both defined as __stdcall (it might not help you much, but this explains different MS specific calling …

Jump to Post

All 2 Replies

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 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.