Question icon in the Title Bar
Question icon in the Title Bar
Hi!
Does one of you know, how I can create the interrogation mark in the title bar next to the minimize-, resize- and close- gadgets ?
Does one of you know, how I can create the interrogation mark in the title bar next to the minimize-, resize- and close- gadgets ?
PB 4 | WinXP_SP2
SetWindowLong_() and #WS_EX_CONTEXHELP
Just modified a bit.
This code was written by Sparkie ( http://www.purebasic.fr/english/viewtopic.php?t=15277 )
Then, just WM_HELP on your callback.
Just modified a bit.
This code was written by Sparkie ( http://www.purebasic.fr/english/viewtopic.php?t=15277 )
Code: Select all
If OpenWindow(0, 100, 100, 320, 300, "SetWindowLong_() Test", #PB_Window_SystemMenu) And CreateGadgetList(WindowID(0))
ButtonGadget(0, 10, 10, 100, 20, "ContextHelp")
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Gadget And EventGadget() = 0
oldStyle = GetWindowLong_(WindowID(0), #GWL_EXSTYLE)
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, oldStyle | #WS_EX_CONTEXTHELP)
DisableGadget(0, 1)
SetWindowPos_(WindowID(0), 0, -1 , -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE | #SWP_NOZORDER | #SWP_FRAMECHANGED | #SWP_SHOWWINDOW)
EndIf
Until event = #PB_Event_CloseWindow
EndIf
End
Why does this give an Illegal Memory Access on the Repeat/Until line?????
Code: Select all
Procedure MyCallback(WindowID,Message,wParam,lParam)
Result=#PB_ProcessPureBasicEvents
Select Message
Case #WM_HELP
Debug "help"
EndSelect
ProcedureReturn Result
EndProcedure
If OpenWindow(0,300,350,400,200,"test",#PB_Window_SystemMenu|#PB_Window_Invisible)
SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_CONTEXTHELP)
ShowWindow_(WindowID(0),#SW_SHOW)
SetWindowCallback(@MyCallback)
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Because you point the callback to the memory position that the variable 'MyCallback' is stored, you should use '@MyCallback()' instead! If you use PB4 you should enable explicit mode to avoid these kind of misstakes..Phoenix wrote:Why does this give an Illegal Memory Access on the Repeat/Until line?????
Code: Select all
Procedure MyCallback(WindowID,Message,wParam,lParam) Result=#PB_ProcessPureBasicEvents Select Message Case #WM_HELP Debug "help" EndSelect ProcedureReturn Result EndProcedure If OpenWindow(0,300,350,400,200,"test",#PB_Window_SystemMenu|#PB_Window_Invisible) SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_CONTEXTHELP) ShowWindow_(WindowID(0),#SW_SHOW) SetWindowCallback(@MyCallback) Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow EndIf
Here is an example i've just made, hope anyone can understand this piece of code.
Update: Added menus ( I misunderstood at first, the WM_HELP is called when you press F1 )
Update: Added menus ( I misunderstood at first, the WM_HELP is called when you press F1 )
Code: Select all
#Button1 = 0
#Button2 = 1
#MenuItem1 = 0
#MenuItem2 = 1
Procedure WinCallback(WinID, message, wParam, lParam)
If message = #WM_HELP
; lparam returns a pointer to the HELPINFO structure
*Help.HELPINFO = lParam
If *Help\iContextType = #HELPINFO_WINDOW
MessageRequester("Help", "Help on:" +Chr(13)+Chr(10) + GetGadgetText(*Help\iCtrlId))
Else
MessageRequester("Help", "Help on:" +Chr(13)+Chr(10) + GetMenuItemText(0, *Help\iCtrlId))
EndIf
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
If OpenWindow(0, 100, 100, 200, 200, "ContextHelp Example", #PB_Window_SystemMenu) And CreateGadgetList(WindowID(0))
ButtonGadget(#Button1, 10, 10, 100, 20, "HelpOnMe 1")
ButtonGadget(#Button2, 10, 40, 100, 20, "HelpOnMe 2")
CreateMenu(0, WindowID(0))
MenuTitle("Simple Menu")
MenuItem(#MenuItem1, "Item 1")
MenuItem(#MenuItem2, "Item 2")
; let's put that <question icon> on the titlebar
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_CONTEXTHELP)
SetWindowPos_(WindowID(0), 0, -1 , -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE | #SWP_NOZORDER | #SWP_FRAMECHANGED | #SWP_SHOWWINDOW)
SetWindowCallback(@WinCallback())
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Last edited by xgp on Tue May 30, 2006 7:47 pm, edited 1 time in total.
- travismcgee
- New User
- Posts: 9
- Joined: Mon May 29, 2006 2:16 am
It might not be possible without some workaround, i think ( hope to be wrong ).Konne wrote:What do I have to change that I can also use the Minimize and Maximize gadget?
Win32 Programmer's Reference wrote:WS_EX_CONTEXTHELP
Includes a question mark in the title bar of the window. When the user clicks the question mark, the cursor changes to a question mark with a pointer. If the user then clicks a child window, the child receives a WM_HELP message. The child window should pass the message to the parent window procedure, which should call the WinHelp function using the HELP_WM_HELP command. The Help application displays a pop-up window that typically contains help for the child window.WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles.