Reinvent the wheel: Center window and add Icon.

BlitzMax Forums/BlitzMax Programming/Reinvent the wheel: Center window and add Icon.

Grisu(Posted 2008) [#1]
Hello everyone.

Sorry to bother you... :/

How can I change the module code for win32 (non gui!) so that:
a) the main window is centered on the desktop by default
b) the window icon is displayed = object file.

Thanks a lot.

Grisu

P.S.: I hate to ask this question each time a new bmx version is released. Anyone else out there feeling the same?


Arowx(Posted 2008) [#2]
Ditto these would both be a very nice to have in the language by default!?

for adding an icon

for positioning the window

Maybe a sticky FAQ or most frequently searched for view of the forum is needed?


Chroma(Posted 2008) [#3]
I thought someone posted that you could just use incbin to change the .exe icon?


Yan(Posted 2008) [#4]
I hate to ask this question each time a new bmx version is released.
Then don't. ;op

It's *always* the same...

In dxgraphics.mod/d3d7graphics.bmx - 'TD3D7Graphics.Create()':-

To add the icon, find...
wc.hCursor=LoadCursorA( Null,Byte Ptr IDC_ARROW )
...and add...
wc.hIcon = LoadIconA(GetModuleHandleA(Null), Byte Ptr(101)) ' Add icon (if included as resource '101')
...below it (or anywhere within the wc definition block).

To centre the window, replace...
Local rect[]=[32,32,width+32,height+32]
...with...
Local rect[4], wx, wy                    ' Centre window
GetWindowRect(GetDesktopWindow(), rect)  '      ~"~
wx = (rect[2] - width) / 2               '      ~"~
wy = (rect[3] - height) / 2              '      ~"~
rect = [wx, wy, wx + width, wy + height] '      ~"~

Done!

If BRL were going to add this, I'd of thought they would have done it by now.


Grisu(Posted 2008) [#5]
Thanks! Someone please make that a sticky!


GfK(Posted 2008) [#6]
I thought someone posted that you could just use incbin to change the .exe icon?
I use a program somebody wrote (Yan, I think) to convert an icon to a .o file, which I can then use with Import.

As for centering the window, be nice if Blitzmax could do this natively/easily, without faffing about.


*(Posted 2008) [#7]
agreed