Returning from Dialog Proc (win32)

Started by
1 comment, last by BrickInTheWall 13 years, 11 months ago
Hi, I have a question about when and how to return from a dialog procedure. I have a pretty big dialog box that does a lot of stuff and quite frankly I'm getting confused. I have sections like this for example:

switch (msg)
{
    case WM_COMMAND:
    {
        switch (LOWORD(wParam))
        {
            case ID_EDITMANP_LB:
            {
                switch (HIWORD(wParam))
                {
                    case LBN_SELCHANGE:
                    {
                        int i = 0;
                  ...
                  ... 
                  ...

I'm simply unsure now when to return TRUE and when to return FALSE. Do I return TRUE if I process WM_COMMAND, but none of the cases of the LOWORD of wParam match? Do I generally return TRUE when I'm in a case like ID_EDITMANP_LB in the example above? Cheers, Brick
Fate fell short this time your smile fades in the summer.
Advertisement
Return FALSE when you want default processing.

If LOWORD(wParam) of WM_COMMAND doesn't equal the id of any control that your code created then you definitely want default processing so return FALSE.

If LOWORD(wParam) of WM_COMMAND equals ID_EDITMANP_LB, which I assume is a list box you created, return TRUE if it's actually a notification you care about and in fact handle -- e.g. say, your app cares about LBN_SELCHANGE, handle it and return TRUE -- otherwise, return FALSE.
alright, thanks! My code has gotten pretty broken since I didn't really pay attention to this. If I have problems fixing it I'll come back, but I think I've got it now.
Fate fell short this time your smile fades in the summer.

This topic is closed to new replies.

Advertisement