window design

Blitz3D Forums/Blitz3D Programming/window design

RRK1020(Posted 2005) [#1]
Does anyone know how I can change the way the window my program runs in looks(B3D)


Picklesworth(Posted 2005) [#2]
Win32....

Bit hard to cover real fast here (sorry, not much time)

These are win32 constants with which you can do that. These and SetWindowLong (maybe api_setWindowLong) in user32.decls are your friend.
I did not make the win32 constants list, but I did the example on the top. You can do all kinds of stuff with those :)




Rook Zimbabwe(Posted 2005) [#3]
That is a lot of code... but what can you really do with it?


Picklesworth(Posted 2005) [#4]
Heh, sorry about the massive post... I should have checked it after posting. Fixed now.

Those win32 constants are almost all of the constants that are to be used alongside the User32 api.

This is a guide for a great deal (if not all of) the Windows api.
http://www.devhood.com/tools/tool_details.aspx?tool_id=563

For instance, we want to change a window's style.
We look in the GWL_ section for the window long flags and find GWL_STYLE. Then for the value of that style setting we look up the a window style section (WS_, WS_EX_,SW_) to find something and set it all up using api_SetWindowLong().
To further my example, the flags for api_SendMessage() are in the WM_ section, labelled Windows Messages
It's all quite fun really, once you get the hang of it. This api is the best thing about Windows in my opinion!


Full user3d.decls is somewhere in this thread:
http://www.blitzbasic.com/Community/posts.php?topic=27586


All kinds of stuff can be done with that code. For instance, in my program, I just resolved an issue where the convex hull generator crashes due to a thing which is hard to write a function to detect. The crash would also crash my main program. In order to fix the problem, I created a seperate exe file which the program calls along with a bunch of command lines (one of which is the main program's window handle). The Convex Hull program then makes itself a child window of the main program, sets a few window style things so that it can't be closed, and does its business. The main program, meanwhile, is trapped in a forever loop until that child window (the CHull program) no longer exists (api_IsWindow()).
Um... Here's that code:
;Executing external file in order to prevent loss of data if the generator crashes
;---------------------------------
;force qhull1.dll to print out only
;face indices and force output
hWnd = SystemProperty("AppHWND")
Exec$=Chr$(34)+"C:\Program Files\Blitz3D\Projects\APOE Stand-alone Rigid Body Editor\CHull_CrashShield.exe"+Chr$(34)+hWnd+" <> "+file$ + " > " + file2$ + " < " + delta
;Pretty funny command line, but it works!
ExecFile Exec$
;res=qhull(file$,file2$,delta,1,1)

;---------------------------------

Local CShieldHWnd=api_GetWindow(hWnd,GW_CHILD)
If CShieldHWnd=0
    Repeat
        Delay 10
        CShieldHWnd=api_GetWindow(hWnd,GW_CHILD)
        If Not CShieldHWnd=0 Then DebugLog "1" : Exit
    Forever
EndIf
Repeat
    Delay 50
    If api_IsWindow(CShieldHWnd)=0 Then DebugLog "2" : Exit
Forever


Another use for win32 is making loading games for big programs with bad load times. You can open up an external .exe which embeds itself in the program which is doing the loading (My self embedder does that: http://www.blitzbasic.com/Community/posts.php?topic=44366), moves itself to match the main program's position (this can be done easily with blitzSys by Rob Hutchinson & Joseph Cox... Sorry, I can't find it), and then has its little game (be it pong, or something more interesting).



Could this be my first ever long and informative post?!


Rook Zimbabwe(Posted 2005) [#5]
Could this be my first ever long and informative post?!
too easy... it is simply too easy... ;)

No seriously that was really helpful and really on task... I learned something new and I appreciate your sharing what you have learned. Great job oh mighty Dill! :)

RZ