Page 1 of 1
Question icon in the Title Bar
Posted: Sun May 28, 2006 11:33 am
by PureBaser
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 ?
Posted: Sun May 28, 2006 2:29 pm
by xgp
SetWindowLong_() and #WS_EX_CONTEXHELP
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
Then, just WM_HELP on your callback.
Posted: Sun May 28, 2006 10:05 pm
by Phoenix
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
Posted: Sun May 28, 2006 10:17 pm
by Pupil
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
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..
Posted: Sun May 28, 2006 11:32 pm
by xgp
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 )
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
Posted: Mon May 29, 2006 2:33 am
by travismcgee
@xgp: Thank you, that will be very useful.
Posted: Tue May 30, 2006 1:10 pm
by PureBaser
Thanks too!

Posted: Tue May 30, 2006 2:27 pm
by rsts
Very nice. Thanks.
cheers
Posted: Tue May 30, 2006 5:50 pm
by Konne
What do I have to change that I can also use the Minimize and Maximize gadget?
Posted: Tue May 30, 2006 7:37 pm
by xgp
Konne wrote:What do I have to change that I can also use the Minimize and Maximize gadget?
It might not be possible without some workaround, i think ( hope to be wrong ).
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.