Hi, I've have put togethor a basic winblitz gui application demostrating resizing the window without stretching 3d graphics and using the minimize/maximize buttons.
2 questions:
I was wondering if there was a better way to do this?
I was wondering if anybody here knows how to limit the minimized size of a window. Ie: I dont want it to be resized less then 640x480.
here's a demo example of what I did. It requires boiled sweets' user32.decls file found in the code archives' user libs section. Thanks for any help.
2 questions:
I was wondering if there was a better way to do this?
I was wondering if anybody here knows how to limit the minimized size of a window. Ie: I dont want it to be resized less then 640x480.
here's a demo example of what I did. It requires boiled sweets' user32.decls file found in the code archives' user libs section. Thanks for any help.
; ! This example requires boiled sweets' user32.decls userlib file... ; located in the code archives / user libs section. ; ; wb3d external winapi styles Include "WB3DStyles.bb" ;########################################################################## ;> Create sizable,minimize/maximize window without 3d gfx stretching ;########################################################################## ; setup blitz3d gfx mode to 2:windowed always | not scaled to desktop resolution desktopwidth=api_GetSystemMetrics(0) desktopheight=api_GetSystemMetrics(1) Graphics3D desktopwidth,desktopheight,0,2 ; setup the "mode 2 blit3d window" with resize, minimize and maximize styles HWND=SystemProperty$("AppHWND") GWL_STYLE=(-16) STYLE=api_GetWindowLong(HWND,GWL_STYLE) api_SetWindowLong(HWND,GWL_STYLE,STYLE Or WS_THICKFRAME Or WS_MAXIMIZEBOX) ; initialize winblitz3d gui and set desired size of window here which will be centered. win_initwidth=640 win_initheight=480 ; sanity check - do not set window diminsions greater then desktop diminsions If win_initwidth>desktopwidth Then win_initwidth=desktopwidth If win_initwidth>desktopwidth Then win_initwidth=desktopwidth ; center window win_centerx=(desktopwidth-win_initwidth)/2 win_centery=(desktopheight-win_initheight)/2 ; init gui/window Global mainWindow = WB3D_InitializeGUI(SystemProperty("AppHwnd"),win_centerx,win_centery,win_initwidth,win_initheight) myAppTitle$ = "Coyote Window - No 3D GFX Strecthing! WB3D_SetQuitMessage myAppTitle$,"Sure To Quit" WB3D_SetGadgetText mainWindow,myAppTitle$ ;########################################################################## ;> Design GUI ;########################################################################## ;client background color cbgred=96 cbggreen=96 cbgblue=255 ; make client area color the same as viewport background color ClsColor cbgred,cbggreen,cbgblue Cls Global panel1, panel2 panel1=WB3D_CreatePanel(0,0,0,0,mainWindow,0) panel2=WB3D_CreatePanel(0,0,0,0,mainWindow,0) WB3D_SetGadgetShape(panel1,0,1,100,WB3D_GadgetHeight(mainWindow)-76) WB3D_SetGadgetShape(panel2,101,1,WB3D_GadgetWidth(mainWindow)-109,70-1) WB3D_FlushEvents() ; menu window_menu=WB3D_WindowMenu(mainWindow) menus = WB3D_WindowMenu(mainWindow) file = WB3D_CreateMenu("&File",0,menus,0) NewItem = WB3D_CreateMenu("&New",1,file,0) OpenItem = WB3D_CreateMenu("&Open",2,file,0) WB3D_CreateMenu("",0,file,0) SaveItem = WB3D_CreateMenu("&Save",3,file,0) WB3D_CreateMenu("",0,file,0) QuitItem = WB3D_CreateMenu("E&xit",4,file,0) WB3D_UpdateWindowMenu(mainWindow) ; create 3 standard push buttons example_button_1 = WB3D_CreateButton("Tool 1",10,40,80,20,panel1,1140948992) example_button_2 = WB3D_CreateButton("Tool 2",10,70,80,20,panel1,1140948992) example_button_3 = WB3D_CreateButton("Tool 3",10,100,80,20,panel1,1140948992) ; make example_button_1 gadget active. WB3D_ActivateGadget example_button_1 Global statusbar=WB3D_CreateStatusBar(mainWindow,"---") WB3D_SetStatusText(statusbar,0,"testing 123") ; cleanup any old creation events, its better to do this before we enter the main ; event loop, when some gadgets are created they generate events. WB3D_FlushEvents Global camera camera = CreateCamera() CameraViewport camera, 100,71,WB3D_GadgetWidth(mainWindow)-108,WB3D_GadgetHeight(mainWindow)-145 cube = CreateCube() PositionEntity cube,0,-1,5 light = CreateLight() ; setup out quit flag, and loop until the flag is set. QUIT = 0 While Not QUIT = 1 TurnEntity cube,1,0,0 UpdateWorld RenderWorld ; generate an internal blitz event Flip ; get an event of the event queue. event = WB3D_WaitEvent() Select event Case WB3D_EVENT_GADGET ; wb3d_eventsouce contains a handle to the selected gadget selected = WB3D_EventSource() Select selected Case example_button_1,example_button_2,example_button_3 WB3D_Notify "Push Buttons","Standard push button pressed!",0 End Select Case WB3D_EVENT_WINDOW_SIZE selected = WB3D_EventData() Select selected Case 2 ; maximized ResizeMyGUI(selected) Case 4 ; minimized ResizeMyGUI(selected) Case 5 ; resized ResizeMyGUI(selected) End Select Case WB3D_EVENT_MENU menuindex = WB3D_EventData() Select menuindex Case 4 ; Exit ; set the flag to leave the loop. QUIT = 1 End Select Case WB3D_EVENT_KEYPRESS ; wb_eventdata holds the key code that was pressed. keypressed = WB3D_EventData() Select keypressed Case WB3D_KEY_ESCAPE ; set the flag to leave the loop. QUIT = 1 End Select Case WB3D_EVENT_WINDOW_CLOSE ; wb3d_eventsource hold the handle to the window that close button was selected window = WB3D_EventSource() Select window Case example_window ; set the flag to leave the loop. QUIT = 1 End Select End Select Wend WB3D_Notify myAppTitle$,"Bye",MB_OK Or MB_ICONASTERISK WB3D_EndGUI() EndGraphics End Function ResizeMyGUI(thisEvent) Cls If thisEvent=5 Then WB3D_SetGadgetShape(mainWindow,WB3D_GadgetX(mainWindow),WB3D_GadgetY(mainWindow),WB3D_GadgetWidth(mainWindow),WB3D_GadgetHeight(mainWindow)) thisWidth=WB3D_GadgetWidth(mainWindow) thisHeight=WB3D_GadgetHeight(mainWindow) WB3D_SetGadgetShape(panel1,0,1,100,thisHeight-76) WB3D_SetGadgetShape(panel2,101,1,thisWidth-109,70-1) WB3D_SetStatusText(statusbar,0,"("+thisWidth+", "+thisHeight+")") CameraViewport camera, 100,71,thisWidth-108,thisHeight-145 WB3D_FlushEvents() Return End Function