Announcement

Collapse
No announcement yet.

ReplyMessage

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ReplyMessage

    ReplyMessage function

    Pierre

    Code:
    #COMPILE EXE '#Win 9.07#
    #DIM ALL
    #REGISTER NONE
    #INCLUDE "Win32Api.inc"
    
    GLOBAL hDlg AS DWORD
    
    $AppName   = "ReplyMessage"
    %LabelInfo = 101
    
    '______________________________________________________________________________
    
    THREAD FUNCTION MsgFunction(BYVAL x AS LONG) AS LONG
     LOCAL Reply AS DWORD
    
     DO
       Reply = SendMessage(hDlg, %WM_APP, 0, 0)
       IF Reply < 10 THEN
         SetDlgItemText(hDlg, %LabelInfo, "Thread exiting at 10:" & STR$(Reply))
         SLEEP 750
       ELSE
         SetDlgItemText(hDlg, %LabelInfo, "Thread exit done")
         EXIT DO
       END IF
     LOOP
    
    END FUNCTION
    '______________________________________________________________________________
    
    CALLBACK FUNCTION DlgProc
     LOCAL  hThread AS DWORD
     STATIC Counter AS DWORD
    
     SELECT CASE CBMSG
    
       CASE %WM_INITDIALOG
         Counter = 0
         THREAD CREATE MsgFunction(0) TO hThread
         THREAD CLOSE hThread TO hThread
    
       CASE %WM_APP
         IF InSendMessageEx(0) = %ISMEX_SEND THEN  'IF InSendMessage() THEN is also valid
           'ISMEX_CALLBACK 0x00000004 From SendMessageCallback function. The thread that sent the message is not blocked.
           'ISMEX_NOTIFY   0x00000002 From SendNotifyMessage function. The thread that sent the message is not blocked.
           'ISMEX_REPLIED  0x00000008 The window procedure has processed the message. The thread that sent the message is no longer blocked.
           'ISMEX_SEND     0x00000001 From SendMessage or SendMessageTimeout function. If ISMEX_REPLIED is not set, the thread that sent the message is blocked.
           INCR Counter
           ReplyMessage(Counter)
           FUNCTION = %TRUE
         END IF
    
      END SELECT
    
    END FUNCTION
    '______________________________________________________________________________
    
    FUNCTION PBMAIN()
     LOCAL hIcon AS DWORD
    
     DIALOG FONT "Segoe UI", 9
     DIALOG NEW %HWND_DESKTOP, $AppName, , , 200, 70, _
     %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_SYSMENU, 0 TO hDlg
    
     hIcon = ExtractIcon(GetModuleHandle(""), "%SystemRoot%\System32\PowrprOf.dll", 1)
     SetClassLong(hDlg, %GCL_HICON, hIcon)
    
     CONTROL ADD LABEL, hDlg, %LabelInfo, "Label1", 5, 25, 190, 10, %SS_CENTER
    
     DIALOG SHOW MODAL hDlg CALL DlgProc
    
     DestroyIcon(hIcon)
    
    END FUNCTION
    '______________________________________________________________________________
    '
    Last edited by Pierre Bellisle; 13 May 2017, 12:26 PM.
Working...
X