Code: Select all
;Manage CreateWindowEx Events
#WindowWidth = 320
#WindowHeight = 240
Global Main_hWnd, BG_hWnd1, BG_hWnd2, BG_hWnd3, CB_hWnd
Procedure Error(errorstring.s)
MessageRequester("Error", errorstring, #MB_ICONERROR)
End
EndProcedure
Procedure HiWord(Var)
ProcedureReturn Var >> 16
EndProcedure
Procedure LoWord(Var)
ProcedureReturn PeekW(@Var)
EndProcedure
Procedure RunApplication()
Shared WndProcMsg.MSG
While GetMessage_(@WndProcMsg,0,0,0)
TranslateMessage_(@WndProcMsg);
DispatchMessage_(@WndProcMsg);
Wend
EndProcedure
Procedure.l WndProc(hWnd,Msg,wParam,lParam)
Select Msg
Case #WM_CONTEXTMENU;this is for some Mouse Right Click on some Gadgets (not all!!!)
; MessageRequester("MOUSE","WM_CONTEXTMENU "+Str(Msg)+" "+Str(LoWord(wParam))+" "+Str(LoWord(wParam))+" "+Str(LoWord(lParam))+" "+Str(HiWord(lParam)), 0)
If wParam = CB_hWnd
MessageRequester("You right-clicked", "in the ComboBox gadget.", 0)
EndIf
Case #WM_PARENTNOTIFY
; MessageRequester("MOUSE","WM_PARENTNOTIFY "+Str(Msg)+" "+Str(LoWord(wParam))+" "+Str(HiWord(wParam))+" "+Str(LoWord(lParam))+" "+Str(HiWord(lParam)), 0)
If LoWord(wParam) = 516 And LoWord(lParam) > 5 And LoWord(lParam) 150 And HiWord(lParam) #WindowWidth-110 And LoWord(lParam) 5 And HiWord(lParam) #WindowWidth-60 And LoWord(lParam) 5 And HiWord(lParam) > 16 ;get height of sized window
Case #WM_ERASEBKGND ;draw window
Case #WM_MOUSEMOVE
xPos.w=lParam
yPos.w=lParam >> 16
Case #WM_CLOSE
MessageRequester("MOUSE","WM_CLOSE "+Str(Msg)+" "+Str(LoWord(wParam))+" "+Str(LoWord(wParam))+" "+Str(LoWord(lParam))+" "+Str(HiWord(lParam)), 0)
PostQuitMessage_(0)
; End
EndSelect
ProcedureReturn DefWindowProc_(hWnd,Msg,wParam,lParam)
EndProcedure
ClassName.s = "ownwindow"
wc.WNDCLASSEX
wc\cbSize = SizeOf(WNDCLASSEX)
wc\style = #CS_HREDRAW | #CS_VREDRAW ;| #CS_GLOBALCLASS
wc\lpfnWndProc = @WndProc()
wc\cbClsExtra = 0
wc\cbWndExtra = 0
wc\hInstance = GetModuleHandle_(0)
wc\hIcon = 0
wc\hCursor = LoadCursor_(#NULL,#IDC_CROSS)
;wc\hbrBackground = GetStockObject_(#LTGRAY_BRUSH); #WHITE_BRUSH);
Brush.LOGBRUSH\lbColor = GetSysColor_(#COLOR_BTNFACE)
wc\hbrBackground = CreateBrushIndirect_(Brush)
wc\lpszMenuName = 0
wc\lpszClassName = @ClassName
wc\hIconSm = 0
If RegisterClassEx_(@wc)
;everithing is OK!
Else
MessageRequester("","Failed to open window...",0)
End
EndIf
;remove #PB_Window_Invisible to make the window invisible
hWnd=CreateWindowEx_(0,"ownwindow",@"DEMO",#PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_Invisible,200,200,#WindowWidth,#WindowHeight,0,0,GetModuleHandle_(0),0)
;OK! without a Button in the TaskBar!
;hWnd=CreateWindowEx_(#WS_EX_TOOLWINDOW,"ownwindow",@"DEMO",#WS_POPUPWINDOW|#WS_DLGFRAME|#WS_CLIPSIBLINGS|#WS_VISIBLE|#DS_MODALFRAME|#DS_3DLOOK,200,200,320,240,0,0,GetModuleHandle_(0),0)
SetWindowPos_(hWnd,#HWND_TOPMOST,(GetSystemMetrics_(#SM_CXSCREEN)/2)-#WindowWidth/2,(GetSystemMetrics_(#SM_CYSCREEN)/2)-240/2,#WindowWidth,#WindowHeight, 0 )
If InitGadget(4) = 0 : Error("Cannot initialize gadgets.") : EndIf
If CreateGadgetList(hWnd) : Else : Error("Could not create gadget list.") : EndIf
CB_hWnd = ComboBoxGadget(0, 5, 5, #WindowWidth-120, 100)
; MessageRequester("Button 1",Str(CB_hWnd),0)
AddGadgetItem(0, -1, "Spaghetti")
AddGadgetItem(0, -1, "Great sole")
AddGadgetItem(0, -1, "Potato omelette")
AddGadgetItem(0, -1, "Fondue chinoise")
AddGadgetItem(0, -1, "Tapioca soup")
AddGadgetItem(0, -1, "Duck liver")
AddGadgetItem(0, -1, "Kebap")
BG_hWnd1 = ButtonGadget(1,5,150,120,24,"Butt1")
; MessageRequester("Button 1",Str(BG_hWnd1),0)
BG_hWnd2 = ButtonGadget(2,#WindowWidth-110,5,50,24,"Butt2")
; MessageRequester("Button 1",Str(BG_hWnd2),0)
BG_hWnd3 = ButtonGadget(3,#WindowWidth-60,5,50,24,"Butt3")
; MessageRequester("Button 2",Str(BG_hWnd3),0)
TextGadget(4, 5, 100, #WindowWidth-10, 24, "Capturing the item-selected event.")
RunApplication()
End
If you look through the code (I hope so...) you can see this is not only my work.
some code is related from El_Choni and some is from Preacher.
Hope this helps...
Have a nice day...