More and more lately I have been noticing functions not running (Unless I move my mouse over my program) so I came up with a test to see if I was "Just seeing things" or if what I thought was happening was really happening.

With this code as a test, If I run in debugger (in Animation mode), then leave my mouse off the the dialog/window the loop for my msg pump stops at the end of the loop until my mouse is over the dialog/window.

Either I am completely misunderstanding the purpose of a message pump or coded poorly in my example (as well as my real) but I can not for the life of me understand how a loop can just "STOP" until the mouse is over the Dialog/Window?????

My real uses a thread to read a port, and display in my main program, but will not display if mouse is not over my program???? (is there a way around this??? or what am I misunderstanding???)

I am not "Missing" messages (that I know of anyways) but more an idea that the messages stack up until the mouse is over my program. (Even though my program is the one with focus when the mouse is not over it)

Also in the example, I am making some other fundamental mistake that when I close, the window disappears, but does not end......Is this related? or something I am missing that should be obvious???

Code:

#COMPILE EXE #DIM ALL #IF NOT %DEF(%WINAPI) #INCLUDE "WIN32API.INC" #ENDIF %IDD_DIALOG1 = 101 %IDC_BUTTON1 = 1001 %IDC_LABEL1 = 1002 DECLARE FUNCTION PBMAIN() DECLARE CALLBACK FUNCTION ShowDIALOG1Proc() DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG DECLARE FUNCTION MsgPumpApp() AS LONG GLOBAL hDlg AS DWORD FUNCTION PBMAIN() ShowDIALOG1 %HWND_DESKTOP END FUNCTION CALLBACK FUNCTION ShowDIALOG1Proc() STATIC TrackMessages AS LONG STATIC LastCbMsg AS LONG LOCAL LastCbMsgText AS STRING SELECT CASE AS LONG CBMSG SELECT CASE TrackMessages CASE %FALSE CASE %TRUE SELECT CASE CBMSG CASE LastCbMsg CASE ELSE ' LastCbMsg = cbmsg ' LastCbMsgText = GetMsgTxt(Cbmsg) ' CONTROL SET TEXT hDlg, %IDC_LABEL1, "Msg = " + LastCbMsgText END SELECT END SELECT END SELECT SELECT CASE AS LONG CBMSG CASE %WM_INITDIALOG ' Initialization handler CASE %WM_NCACTIVATE STATIC hWndSaveFocus AS DWORD IF ISFALSE CBWPARAM THEN ' Save control focus hWndSaveFocus = GetFocus() ELSEIF hWndSaveFocus THEN ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 END IF CASE %WM_COMMAND ' Process control notifications SELECT CASE AS LONG CBCTL CASE %IDC_BUTTON1 IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN TrackMessages = %TRUE END IF CASE %IDC_LABEL1 END SELECT CASE %WM_DESTROY PostQuitMessage 0'%WM_QUIT END SELECT END FUNCTION FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG LOCAL lRslt AS LONG DIALOG NEW hParent, "Dialog1", 70, 70, 197, 59, %WS_POPUP OR %WS_BORDER _ OR %WS_DLGFRAME OR %WS_THICKFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _ %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_CLIPSIBLINGS OR _ %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _ %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _ %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg CONTROL ADD BUTTON, hDlg, %IDC_BUTTON1, "Start Test", 10, 5, 75, 20 CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "Once Started DO NOTTT move mouse " + _ "or touch anything", 5, 35, 190, 20 DIALOG SHOW MODELESS hDlg, CALL ShowDIALOG1Proc TO lRslt MsgPumpApp FUNCTION = lRslt END FUNCTION FUNCTION MsgPumpApp()AS LONG LOCAL tmsg AS TagMsg ' message information '*** Acquire and dispatch messages until a WM_QUIT message is received. WHILE GetMessage(tmsg, BYVAL %NULL, 0, 0)<> -1 TranslateMessage tmsg DispatchMessage tmsg ' if tmsg.wParam = %WM_QUIT then exit do WEND FUNCTION = tmsg.wParam END FUNCTION FUNCTION GetMsgTxt(iMsgNum AS LONG) AS STRING SELECT CASE iMsgNum CASE %WM_USER:FUNCTION = "%WM_USER" CASE %WM_CREATE:FUNCTION = "%WM_CREATE" CASE %WM_DESTROY:FUNCTION = "%WM_DESTROY" CASE %WM_ENABLE:FUNCTION = "%WM_ENABLE" CASE %WM_MOVE:FUNCTION = "%WM_MOVE" CASE %WM_SIZE:FUNCTION = "%WM_SIZE" CASE %WM_ACTIVATE:FUNCTION = "%WM_ACTIVATE" CASE %WM_SHOWWINDOW:FUNCTION = "%WM_SHOWWINDOW" CASE %WM_SETFOCUS:FUNCTION = "%WM_SETFOCUS" CASE %WM_KILLFOCUS:FUNCTION = "%WM_KILLFOCUS" CASE %WM_SETREDRAW:FUNCTION = "%WM_SETREDRAW" CASE %WM_SETTEXT:FUNCTION = "%WM_SETTEXT" CASE %WM_GETTEXT:FUNCTION = "%WM_GETTEXT" CASE %WM_GETTEXTLENGTH:FUNCTION = "%WM_GETTEXTLENGTH" CASE %WM_PAINT:FUNCTION = "%WM_PAINT" CASE %WM_CLOSE:FUNCTION = "%WM_CLOSE" CASE %WM_QUERYENDSESSION:FUNCTION = "%WM_QUERYENDSESSION" CASE %WM_QUIT:FUNCTION = "%WM_QUIT" CASE %WM_QUERYOPEN:FUNCTION = "%WM_QUERYOPEN" CASE %WM_ERASEBKGND:FUNCTION = "%WM_ERASEBKGND" CASE %WM_SYSCOLORCHANGE:FUNCTION = "%WM_SYSCOLORCHANGE" CASE %WM_ENDSESSION:FUNCTION = "%WM_ENDSESSION" CASE %WM_WININICHANGE,%WM_SETTINGCHANGE:FUNCTION = "%WM_WININICHANGE,%WM_SETTINGCHANGE" CASE %WM_DEVMODECHANGE:FUNCTION = "%WM_DEVMODECHANGE" CASE %WM_ACTIVATEAPP:FUNCTION = "%WM_ACTIVATEAPP" CASE %WM_FONTCHANGE:FUNCTION = "%WM_FONTCHANGE" CASE %WM_TIMECHANGE:FUNCTION = "%WM_TIMECHANGE" CASE %WM_CANCELMODE:FUNCTION = "%WM_CANCELMODE" CASE %WM_SETCURSOR:FUNCTION = "%WM_SETCURSOR" CASE %WM_HELP:FUNCTION = "%WM_HELP" CASE %WM_MOUSEACTIVATE:FUNCTION = "%WM_MOUSEACTIVATE" CASE %WM_CHILDACTIVATE:FUNCTION = "%WM_CHILDACTIVATE" CASE %WM_QUEUESYNC:FUNCTION = "%WM_QUEUESYNC" CASE %WM_GETMINMAXINFO:FUNCTION = "%WM_GETMINMAXINFO" CASE %WM_PAINTICON:FUNCTION = "%WM_PAINTICON" CASE %WM_ICONERASEBKGND:FUNCTION = "%WM_ICONERASEBKGND" CASE %WM_NEXTDLGCTL:FUNCTION = "%WM_NEXTDLGCTL" CASE %WM_SPOOLERSTATUS:FUNCTION = "%WM_SPOOLERSTATUS" CASE %WM_DRAWITEM:FUNCTION = "%WM_DRAWITEM" CASE %WM_MEASUREITEM:FUNCTION = "%WM_MEASUREITEM" CASE %WM_DELETEITEM:FUNCTION = "%WM_DELETEITEM" CASE %WM_VKEYTOITEM:FUNCTION = "%WM_VKEYTOITEM" CASE %WM_CHARTOITEM:FUNCTION = "%WM_CHARTOITEM" CASE %WM_SETFONT:FUNCTION = "%WM_SETFONT" CASE %WM_GETFONT:FUNCTION = "%WM_GETFONT" CASE %WM_SETHOTKEY:FUNCTION = "%WM_SETHOTKEY" CASE %WM_GETHOTKEY:FUNCTION = "%WM_GETHOTKEY" CASE %WM_QUERYDRAGICON:FUNCTION = "%WM_QUERYDRAGICON" CASE %WM_COMPAREITEM:FUNCTION = "%WM_COMPAREITEM" CASE %WM_COMPACTING:FUNCTION = "%WM_COMPACTING" CASE %WM_OTHERWINDOWCREATED:FUNCTION = "%WM_OTHERWINDOWCREATED" CASE %WM_OTHERWINDOWDESTROYED:FUNCTION = "%WM_OTHERWINDOWDESTROYED" CASE %WM_COMMNOTIFY:FUNCTION = "%WM_COMMNOTIFY" CASE %WM_WINDOWPOSCHANGING:FUNCTION = "%WM_WINDOWPOSCHANGING" CASE %WM_WINDOWPOSCHANGED:FUNCTION = "%WM_WINDOWPOSCHANGED" CASE %WM_POWER:FUNCTION = "%WM_POWER" CASE %WM_COPYDATA:FUNCTION = "%WM_COPYDATA" CASE %WM_CANCELJOURNAL:FUNCTION = "%WM_CANCELJOURNAL" CASE %WM_NOTIFY:FUNCTION = "%WM_NOTIFY" CASE %WM_INPUTLANGUAGECHANGEREQUEST:FUNCTION = "%WM_INPUTLANGUAGECHANGEREQUEST" CASE %WM_INPUTLANGUAGECHANGE:FUNCTION = "%WM_INPUTLANGUAGECHANGE" CASE %WM_TCARD:FUNCTION = "%WM_TCARD" CASE %WM_USERCHANGED:FUNCTION = "%WM_USERCHANGED" CASE %WM_NOTIFYFORMAT:FUNCTION = "%WM_NOTIFYFORMAT" CASE %WM_CONTEXTMENU:FUNCTION = "%WM_CONTEXTMENU" CASE %WM_STYLECHANGING:FUNCTION = "%WM_STYLECHANGING" CASE %WM_STYLECHANGED:FUNCTION = "%WM_STYLECHANGED" CASE %WM_DISPLAYCHANGE:FUNCTION = "%WM_DISPLAYCHANGE" CASE %WM_GETICON:FUNCTION = "%WM_GETICON" CASE %WM_SETICON:FUNCTION = "%WM_SETICON" CASE %WM_NCCREATE:FUNCTION = "%WM_NCCREATE" CASE %WM_NCDESTROY:FUNCTION = "%WM_NCDESTROY" CASE %WM_NCCALCSIZE:FUNCTION = "%WM_NCCALCSIZE" CASE %WM_NCHITTEST:FUNCTION = "%WM_NCHITTEST" CASE %WM_NCPAINT:FUNCTION = "%WM_NCPAINT" CASE %WM_NCACTIVATE:FUNCTION = "%WM_NCACTIVATE" CASE %WM_GETDLGCODE:FUNCTION = "%WM_GETDLGCODE" CASE %WM_NCMOUSEMOVE:FUNCTION = "%WM_NCMOUSEMOVE" CASE %WM_NCLBUTTONDOWN:FUNCTION = "%WM_NCLBUTTONDOWN" CASE %WM_NCLBUTTONUP:FUNCTION = "%WM_NCLBUTTONUP" CASE %WM_NCLBUTTONDBLCLK:FUNCTION = "%WM_NCLBUTTONDBLCLK" CASE %WM_NCRBUTTONDOWN:FUNCTION = "%WM_NCRBUTTONDOWN" CASE %WM_NCRBUTTONUP:FUNCTION = "%WM_NCRBUTTONUP" CASE %WM_NCRBUTTONDBLCLK:FUNCTION = "%WM_NCRBUTTONDBLCLK" CASE %WM_NCMBUTTONDOWN:FUNCTION = "%WM_NCMBUTTONDOWN" CASE %WM_NCMBUTTONUP:FUNCTION = "%WM_NCMBUTTONUP" CASE %WM_NCMBUTTONDBLCLK:FUNCTION = "%WM_NCMBUTTONDBLCLK" CASE %WM_KEYDOWN, %WM_KEYFIRST:FUNCTION = "%WM_KEYDOWN" CASE %WM_KEYUP:FUNCTION = "%WM_KEYUP" CASE %WM_CHAR:FUNCTION = "%WM_CHAR" CASE %WM_DEADCHAR:FUNCTION = "%WM_DEADCHAR" CASE %WM_SYSKEYDOWN:FUNCTION = "%WM_SYSKEYDOWN" CASE %WM_SYSKEYUP:FUNCTION = "%WM_SYSKEYUP" CASE %WM_SYSCHAR:FUNCTION = "%WM_SYSCHAR" CASE %WM_SYSDEADCHAR:FUNCTION = "%WM_SYSDEADCHAR" CASE %WM_KEYLAST:FUNCTION = "%WM_KEYLAST" CASE %WM_INITDIALOG:FUNCTION = "%WM_INITDIALOG" CASE %WM_COMMAND:FUNCTION = "%WM_COMMAND" CASE %WM_SYSCOMMAND:FUNCTION = "WM_SYSCOMMAND" CASE %WM_TIMER:FUNCTION = "%WM_TIMER" CASE %WM_HSCROLL:FUNCTION = "%WM_HSCROLL" CASE %WM_VSCROLL:FUNCTION = "%WM_VSCROLL" CASE %WM_INITMENU:FUNCTION = "%WM_INITMENU" CASE %WM_INITMENUPOPUP:FUNCTION = "%WM_INITMENUPOPUP" CASE %WM_MENUSELECT:FUNCTION = "%WM_MENUSELECT" CASE %WM_MENUCHAR:FUNCTION = "%WM_MENUCHAR" CASE %WM_ENTERIDLE:FUNCTION = "%WM_ENTERIDLE" CASE %WM_CTLCOLORMSGBOX:FUNCTION = "%WM_CTLCOLORMSGBOX" CASE %WM_CTLCOLOREDIT:FUNCTION = "%WM_CTLCOLOREDIT" CASE %WM_CTLCOLORLISTBOX:FUNCTION = "%WM_CTLCOLORLISTBOX" CASE %WM_CTLCOLORBTN:FUNCTION = "%WM_CTLCOLORBTN" CASE %WM_CTLCOLORDLG:FUNCTION = "%WM_CTLCOLORDLG" CASE %WM_CTLCOLORSCROLLBAR:FUNCTION = "%WM_CTLCOLORSCROLLBAR" CASE %WM_CTLCOLORSTATIC:FUNCTION = "%WM_CTLCOLORSTATIC" CASE %WM_MOUSEMOVE,%WM_MOUSEFIRST:FUNCTION = "%WM_MOUSEMOVE" CASE %WM_LBUTTONDOWN:FUNCTION = "%WM_LBUTTONDOWN" CASE %WM_LBUTTONUP:FUNCTION = "%WM_LBUTTONUP" CASE %WM_LBUTTONDBLCLK:FUNCTION = "%WM_LBUTTONDBLCLK" CASE %WM_RBUTTONDOWN:FUNCTION = "%WM_RBUTTONDOWN" CASE %WM_RBUTTONUP:FUNCTION = "%WM_RBUTTONUP" CASE %WM_RBUTTONDBLCLK:FUNCTION = "%WM_RBUTTONDBLCLK" CASE %WM_MBUTTONDOWN:FUNCTION = "%WM_MBUTTONDOWN" CASE %WM_MBUTTONUP:FUNCTION = "%WM_MBUTTONUP" CASE %WM_MBUTTONDBLCLK:FUNCTION = "%WM_MBUTTONDBLCLK" CASE %WM_MOUSEWHEEL,%WM_MOUSELAST:FUNCTION = "%WM_MOUSEWHEEL" CASE %WM_PARENTNOTIFY:FUNCTION = "%WM_PARENTNOTIFY" CASE %WM_ENTERMENULOOP:FUNCTION = "%WM_ENTERMENULOOP" CASE %WM_EXITMENULOOP:FUNCTION = "%WM_EXITMENULOOP" CASE %WM_SIZING:FUNCTION = "%WM_SIZING" CASE %WM_CAPTURECHANGED:FUNCTION = "%WM_CAPTURECHANGED" CASE %WM_MOVING:FUNCTION = "%WM_MOVING" CASE %WM_POWERBROADCAST:FUNCTION = "%WM_POWERBROADCAST" CASE %WM_DEVICECHANGE:FUNCTION = "%WM_DEVICECHANGE" CASE %WM_MDICREATE:FUNCTION = "%WM_MDICREATE" CASE %WM_MDIDESTROY:FUNCTION = "%WM_MDIDESTROY" CASE %WM_MDIACTIVATE:FUNCTION = "%WM_MDIACTIVATE" CASE %WM_MDIRESTORE:FUNCTION = "%WM_MDIRESTORE" CASE %WM_MDINEXT:FUNCTION = "%WM_MDINEXT" CASE %WM_MDIMAXIMIZE:FUNCTION = "%WM_MDIMAXIMIZE" CASE %WM_MDITILE:FUNCTION = "%WM_MDITILE" CASE %WM_MDICASCADE:FUNCTION = "%WM_MDICASCADE" CASE %WM_MDIICONARRANGE:FUNCTION = "%WM_MDIICONARRANGE" CASE %WM_MDIGETACTIVE:FUNCTION = "%WM_MDIGETACTIVE" CASE %WM_MDISETMENU:FUNCTION = "%WM_MDISETMENU" CASE %WM_DROPFILES:FUNCTION = "%WM_DROPFILES" CASE %WM_MDIREFRESHMENU:FUNCTION = "%WM_MDIREFRESHMENU" CASE %WM_MOUSEHOVER:FUNCTION = "%WM_MOUSEHOVER" CASE %WM_MOUSELEAVE:FUNCTION = "%WM_MOUSELEAVE" CASE %WM_CUT:FUNCTION = "%WM_CUT" CASE %WM_COPY:FUNCTION = "%WM_COPY" CASE %WM_PASTE:FUNCTION = "%WM_PASTE" CASE %WM_CLEAR:FUNCTION = "%WM_CLEAR" CASE %WM_UNDO:FUNCTION = "%WM_UNDO" CASE %WM_RENDERFORMAT:FUNCTION = "%WM_RENDERFORMAT" CASE %WM_RENDERALLFORMATS:FUNCTION = "%WM_RENDERALLFORMATS" CASE %WM_DESTROYCLIPBOARD:FUNCTION = "%WM_DESTROYCLIPBOARD" CASE %WM_DRAWCLIPBOARD:FUNCTION = "%WM_DRAWCLIPBOARD" CASE %WM_PAINTCLIPBOARD:FUNCTION = "%WM_PAINTCLIPBOARD" CASE %WM_VSCROLLCLIPBOARD:FUNCTION = "%WM_VSCROLLCLIPBOARD" CASE %WM_SIZECLIPBOARD:FUNCTION = "%WM_SIZECLIPBOARD" CASE %WM_ASKCBFORMATNAME:FUNCTION = "%WM_ASKCBFORMATNAME" CASE %WM_CHANGECBCHAIN:FUNCTION = "%WM_CHANGECBCHAIN" CASE %WM_HSCROLLCLIPBOARD:FUNCTION = "%WM_HSCROLLCLIPBOARD" CASE %WM_QUERYNEWPALETTE:FUNCTION = "%WM_QUERYNEWPALETTE" CASE %WM_PALETTEISCHANGING:FUNCTION = "%WM_PALETTEISCHANGING" CASE %WM_PALETTECHANGED:FUNCTION = "%WM_PALETTECHANGED" CASE %WM_HOTKEY:FUNCTION = "%WM_HOTKEY" CASE %WM_PRINTCLIENT:FUNCTION = "%WM_PRINTCLIENT" CASE %WM_PENWINFIRST:FUNCTION = "%WM_PENWINFIRST" CASE %WM_PENWINLAST:FUNCTION = "%WM_PENWINLAST" CASE %WM_ENTERSIZEMOVE:FUNCTION = "WM_ENTERSIZEMOVE" CASE %WM_EXITSIZEMOVE:FUNCTION = "WM_EXITSIZEMOVE" CASE %WM_NULL:FUNCTION = "%WM_NULL" CASE ELSE:FUNCTION = "Custom Msg: " + FORMAT$(iMsgNum) END SELECT END FUNCTION

Either I am completely misunderstanding the purpose of a message pump or coded poorly in my example (as well as my real) but I can not for the life of me understand how a loop can just "STOP" until the mouse is over the Dialog/Window?????

My real uses a thread to read a port, and display in my main program, but will not display if mouse is not over my program???? (is there a way around this??? or what am I misunderstanding???)

I am not "Missing" messages (that I know of anyways) but more an idea that the messages stack up until the mouse is over my program. (Even though my program is the one with focus when the mouse is not over it)

Also in the example, I am making some other fundamental mistake that when I close, the window disappears, but does not end......Is this related? or something I am missing that should be obvious???

## Comment