@José Roca

Windows specific questions.
Post Reply
deltarho[1859]
Posts: 4305
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

@José Roca

Post by deltarho[1859] »

Hi José

I wonder if you help me out on an issue.

WM_INITDIALOG seems to getting ignored.

Here is a piece from your CWindow Template in Paul's WinFBE.

I have added Case WM_INITDIALOG with a Messagebox and a MessageBox within the Escape key capture.

Pressing the Escape key gives us "I am at Escape key."

However, I should be getting "I am at WM_INITDIALOG." before the Dialog is drawn but I am not getting anything.

I have been scratching my head over this for a few days and double checked WM_INITDIALOG at MSDN.

I have used WM_INITDIALOG quite a lot with PowerBASIC GUIs and need to do some subclassing initialization with a new project. Obviously, a static variable approach can be used as a workaround but I don't want to have an 'If/End If' construct executed everytime we enter WndProc.

Cheers.

Code: Select all

FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
 
  SELECT CASE uMsg
 
    Case WM_INITDIALOG
      MessageBox HWnd, "I am at WM_INITDIALOG.", "Test", MB_OK
 
    CASE WM_COMMAND
      SELECT CASE GET_WM_COMMAND_ID(wParam, lParam)
        CASE IDCANCEL
          ' // If ESC key pressed, close the application by sending an WM_CLOSE message
          IF GET_WM_COMMAND_CMD(wParam, lParam) = BN_CLICKED THEN
            MessageBox HWnd, "I am at Escape key.", "Test", MB_OK
            SendMessageW hwnd, WM_CLOSE, 0, 0
            EXIT FUNCTION
          END IF
      END SELECT
Josep Roca
Posts: 564
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: @José Roca

Post by Josep Roca »

WM_INITDIALOG only works with dialogs, not with SDK windows, that use WM_CREATE.

Use:

Code: Select all

      CASE WM_CREATE
         MessageBox HWnd, "I am at WM_CREATE.", "Test", MB_OK
         EXIT FUNCTION
deltarho[1859]
Posts: 4305
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: @José Roca [Solved]

Post by deltarho[1859] »

@José Roca

After 14 years of GUI programming I did not know that. Of course, you have let the cat out of the bag by letting folk know that I am not a SDK programmer. No shame in that - I have knocked out some reasonable dialogs over the years using PowerBASIC's DDT.

I probably never will be a SDK programmer, too much like hard work for an oldie like me, but will, one of these days, regard myself as a WinFBX programmer. I have some way to go before I get my WinFBX wings.

Thanks for getting back to me so quickly - you have made my day.
Post Reply