Date: 02-16-2022
Return to Index
created by gbSnippets
'An online tutorial on templates can be found at:
'http://www.garybeene.com/power/pb-tutor-templates.htm
'Use this template by copying everything below "'Copy below here:"
'and put in a file with a ".pbtpl" extension under pbwin90\bin.
'When PB IDE starts, the template will be available under the
'toolbar "Create New File" dropdown menu.
'Copy below here:
1
.bas
Standard: Dialog + Selected Messages
#Compile EXE
#Dim All
%Unicode=1
#Debug Error On 'catch array/pointer errors - OFF in production
#Debug Display On 'display untrapped errors - OFF in production
#Tools Off 'use ON only when needed for Trace/Profile/CallStk
#Include "win32api.inc"
'use these inside procedures:
'#Debug Print "msg" 'on as-needed basis only
'#Debug Code ON 'ignored in production, use OFF for speed in development testing
Function PBMain () As Long
Local hDlg As Dword
MakeDialog(hDlg)
End Function
Sub MakeDialog(hDlg As Dword)
Dialog New Pixels, 0, "Test",300,300,200,200, %WS_OverlappedWindow To hDlg
'... test code goes here
Dialog Show Modal hDlg Call DlgProc
End Sub
Sub CPrint (SOut As String) 'Semen Matusovski's CPrint code:
Static hConsole As Long, cWritten As Long
If hConsole = 0 Then AllocConsole: hConsole = GetStdHandle(-11&)
WriteConsole hConsole, ByCopy sOut + $CrLf, Len(sOut) + 2, cWritten, ByVal 0&
End Sub
CallBack Function DlgProc() As Long
'Console message list
Static iMsgCount&
CPrint Str$(iMsgCount&)+ " " + WinMsg(CB.Msg)
Incr iMsgCount&
Select Case CB.Msg
'life-cycle
Case %WM_Create 'when an application requests that a window be created
'after window is created, but before it becomes visible
Case %WM_InitDialog 'immediately before a dialog box is displayed
'typically used to initialize controls and carry out any other
'initialization tasks that affect the appearance of the dialog box.
Case %WM_Destroy 'window is being destroyed
'after windows is removed from screen (children still exist)
'control notifications
Case %WM_Command 'user selects a command item from a menu
'control sends a notification message to its parent window
'accelerator keystroke is translated.
Case %WM_Notify 'by control to its parent window when an event has occurred
'resize
Case %WM_Size 'after its size has changed.
Case %WM_GETMINMAXINFO 'size/position of window is about to change
'mouse click
Case %WM_PARENTNOTIFY 'sent to parent when child window is create/destrory
'sent to parent when user clicks mouse button over child
Case %WM_SYSCOMMAND 'user choose command from Window menu, max/min/restore/close buttons
'mouse movement
Case %WM_SETCURSOR 'sent if mouse causes cursor to move
Case %WM_MouseMove 'when cursor moves
'keyboard
Case %WM_Char 'to window with keyboard focus when WM_KEYDOWN message is translated
'by the TranslateMessage function. contains the character code of the
'key that was pressed.
Case %WM_GETDLGCODE 'intercept keyboard input to child control
Case %WM_Help 'F1 is pressed
'application status
Case %WM_ActivateApp 'focus returns to app from another app
Case %WM_Activate 'sent to both the window being activated and the window
'being deactivated.
'graphic/drawing events
Case %WM_ERASEBKGND 'sent when the window background must be erased (such as resizing)
Case %WM_Paint 'set when request is made to paint a portion of an application's window.
'recurring events
Case %WM_Timer 'when a timer expires
'menu activity
Case %WM_INITMENUPOPUP 'when pop-up menu is about to become active
Case %WM_CONTEXTMENU 'user clicked the right mouse button (right-clicked) in a window.
Case %WM_MENUSELECT 'sent when user selects a menu item
'user action
Case %WM_PASTE 'application sends a WM_PASTE message to an edit control or combobox
Case %WM_DROPFILES 'sent when user drops file on application that's is registered as file recipient
End Select
'WM_CREATE
'The WM_CREATE message is sent when an application requests that a window
'be created by calling the CreateWindowEx or CreateWindow function. (The
'message is sent before the function returns.) The window procedure of the
'new window receives this message after the window is created, but before
'the window becomes visible.
'WM_INITDIALOG
'The WM_INITDIALOG message is sent to the dialog box procedure immediately
'before a dialog box is displayed. Dialog box procedures typically use this
'message to initialize controls and carry out any other initialization tasks
'that affect the appearance of the dialog box.
'WM_DESTROY
'The WM_DESTROY message is sent when a window is being destroyed. It is
'sent to the window procedure of the window being destroyed after the
'window is removed from the screen. This message is sent first to the
'window being destroyed and then to the child windows (if any) as they
'are destroyed. During the processing of the message, it can be assumed
'that all child windows still exist.
'WM_COMMAND
'The WM_COMMAND message is sent when the user selects a command item from
'a menu, when a control sends a notification message to its parent window,
'or when an accelerator keystroke is translated.
'WM_NOTIFY
'WM_NOTIFY Sent by a common control to its parent window when an event has
'occurred or the control requires some information.
'WM_SIZE
'The WM_SIZE message is sent to a window after its size has changed.
'WM_GETMINMAXINFO
'The WM_GETMINMAXINFO message is sent to a window when the size or position of
'the window is about to change. An application can use this message to override
'the window's default maximized size and position, or its default minimum or
'maximum tracking size.
'WM_PARENTNOTIFY
'The WM_PARENTNOTIFY message is sent to the parent of a child window when
'the child window is created or destroyed, or when the user clicks a mouse
'button while the cursor is over the child window. When the child window is
'being created, the system sends WM_PARENTNOTIFY just before the CreateWindow
'or CreateWindowEx function that creates the window returns. When the child
'window is being destroyed, the system sends the message before any processing
'to destroy the window takes place.
'WM_SYSCOMMAND
'WM_SYSCOMMAND. A window receives this message when the user chooses a
'command from the Window menu (formerly known as the system or control
'menu) or when the user chooses the maximize button, minimize button,
'restore button, or close button.
'WM_SETCURSOR
'The WM_SETCURSOR message is sent to a window if the mouse causes the cursor
'to move within a window and mouse input is not captured.
'WM_MOUSEMOVE
'The WM_MOUSEMOVE message is posted to a window when the cursor moves. If
'the mouse is not captured, the message is posted to the window that
'contains the cursor. Otherwise, the message is posted to the window
'that has captured the mouse.
'WM_CHAR
'The WM_CHAR message is posted to the window with the keyboard focus when
'a WM_KEYDOWN message is translated by the TranslateMessage function. The
'WM_CHAR message contains the character code of the key that was pressed.
'WM_GETDLGCODE
'The WM_GETDLGCODE message is sent to the window procedure associated with
'a control. By default, the system handles all keyboard input to the control;
'the system interprets certain types of keyboard input as dialog box navigation
'keys. To override this default behavior, the control can respond to the
'WM_GETDLGCODE message to indicate the types of input it wants to process itself.
'WM_ACTIVATEAPP
'The WM_ACTIVATEAPP message is sent when a window belonging to a different
'application than the active window is about to be activated. The message is
'sent to the application whose window is being activated and to the application
'whose window is being deactivated.
'WM_ACTIVATE
'The WM_ACTIVATE message is sent to both the window being activated and the
'window being deactivated. If the windows use the same input queue, the message
'is sent synchronously, first to the window procedure of the top-level window
'being deactivated, then to the window procedure of the top-level window being
'activated. If the windows use different input queues, the message is sent
'asynchronously, so the window is activated immediately.
'WM_NCACTIVATE
'The WM_NCACTIVATE message is sent to a window when its nonclient area needs to
'be changed to indicate an active or inactive state.
'WM_SYSCOLORCHANGE
'The WM_SYSCOLORCHANGE message is sent to all top-level windows when a change is
'made to a system color setting.
'WM_ERASEBKGND
'The WM_ERASEBKGND message is sent when the window background must be erased
'(for example, when a window is resized). The message is sent to prepare an
'invalidated portion of a window for painting.
'WM_PAINT
'WM_PAINT. Sent by an application when Windows or another application makes a
'request to paint a portion of an application's window.
'WM_TIMER
'The WM_TIMER message is posted to the installing thread's message queue when a timer expires.
'WM_INITMENUPOPUP
'WM_INITMENUPOPUP. This message is sent when a pop-up menu is about to become
'active. This enables an application to modify the pop-up menu before it is
'displayed, without changing the entire menu.
'WM_CONTEXTMENU
'The WM_CONTEXTMENU message notifies a window that the user clicked the right
'mouse button (right-clicked) in the window.
'WM_MENUSELECT
'The WM_MENUSELECT message is sent to a menu's owner window when the user selects a menu item.
'WM_PASTE
'WM_PASTE. An application sends a WM_PASTE message to an edit control or combo
'box to copy the current content of the clipboard to the edit control at the current
'caret position. Data is inserted only if the clipboard contains data in CF_TEXT format.
'WM_DRAGDROP
'WM_DRAGDROP. Sent when the user drops a file on the window of an application that has
'registered itself as a recipient of dropped files.
End Function
'gbs_00252
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm