ACtually my first question here is unrelated:

How to center a window? Isn't there a WS_CENTERWINDOW or something? I can't find it on MSDN.

Main question:

Somebody (I think it was bitRAKE) said something about somebody (I think it was f0dder) knew how to make C progs smaller in exe size. Can I get an explanation (or the likes) on that?

thanks
Posted on 2002-01-01 21:48:39 by lackluster
Well, for the biggest reduction...

Compile your C programs in a C compiler like lcc. Not a C++ compiler.

C   : 3kb

C++ : 50kb
Posted on 2002-01-01 22:32:50 by ChimpFace9000


CenterScreen proc hwnd:HWND
LOCAL DlgHeight:DWORD
LOCAL DlgWidth:DWORD
LOCAL DlgRect:RECT
LOCAL DesktopRect:RECT

invoke GetWindowRect,hwnd,ADDR DlgRect
invoke GetDesktopWindow
mov ecx,eax
invoke GetWindowRect,ecx,addr DesktopRect
push 0
mov eax,DlgRect.bottom
sub eax,DlgRect.top
mov DlgHeight,eax
push eax
mov eax,DlgRect.right
sub eax,DlgRect.left
mov DlgWidth,eax
push eax
mov eax,DesktopRect.bottom
sub eax,DlgHeight
shr eax,1
push eax
mov eax,DesktopRect.right
sub eax,DlgWidth
shr eax,1
push eax
push hwnd
call MoveWindow
ret
CenterScreen endp


Iczelion wrote this one in one of his tuts...
Posted on 2002-01-01 23:51:58 by JimmyClif
Talk about size, check out the 512 byte OpenGL Demo on the Hugi Disk Mag 24!
Posted on 2002-01-02 00:10:12 by bitRAKE

Compile your C programs in a C compiler like lcc. Not a C++ compiler.


That makes no difference, as long as you know your compiler+linker
settings, and code "properly".

I bet some of the "how to get stuff small" threads pop up if you
search the board for FILEALIGN .

And as for the 512byte hugi thingy... that probably isn't compatible
with all windows versions, making it useless (but still fun ;) )
Posted on 2002-01-02 00:11:43 by f0dder
He did versions for compatiblity. (Even XP) :rolleyes:
It's cool for 512 bytes - check it out!
Posted on 2002-01-02 00:58:52 by bitRAKE
Contrary to popular belief a C\Win32 EXE can be as small as
an ASM\Win32 EXE.

The methods employed to create compact C\Win32 EXE's are:-

--File alignment (Linker setting)

--Optimise for size instead of speed (compiler setting)

--Compile for DLL runtime library (on VC++ 6)

--PE Segment merging (Not recommended)

--Start-up code removal, ie define your own entry point

--Intelligent coding (the hardest part)

Using the above methods you can create a Win32 "Hello World!"
ie. display a message box, in under 2Kb.
Posted on 2002-01-02 04:31:29 by fybo
Using the above methods you can create a Win32 "Hello World!"
ie. display a message box, in under 2Kb.

Hi FYBO

Do you have maybe the Visual C++ workspace, and C fileof this 2 k Hello World, that you could share,if you can I know you have to
send then up as textfiles, or paste them on the board because , of the types of files allowed to be uploaded ,but that would be cool,
I tried to follow the things you said but I got loss,
But I'm kind of familiar with Visual C console projects

Thanks Andy
Posted on 2002-01-02 15:44:26 by andy981
JimmyClif,

Is that the only way to center a window? I mean I want it to start center screen, like when I do createwindow(ex) there's no like WS_EX_CENTERSCREEN style or anything?

<hr>

-Beware of Newbie Question-

What exactly is FILEALIGN (looking for brief or in-depth explanation (or link))?
Posted on 2002-01-02 19:01:30 by lackluster
If you want to optimize with visual C++ make sure you have at least the professional edition I have the standard eddition and I found it it dosen't include the optimizing compiler.
Posted on 2002-01-02 19:37:11 by Quantum
Well, I'm kinda poor so I only have borland's freecommandlinetools. :(
Posted on 2002-01-02 19:40:28 by lackluster
For an in-depth explanation of filealign, see the PE documentation.

If you want a good free compiler, check out www.openwatcom.org .
Watcom used to be the best compiler in the old days, and now that
it's free, it's probably at least the best *free* compiler.
Posted on 2002-01-02 20:16:46 by f0dder
thanx for that link fodder I've had it with the buggy lcc-win32
Posted on 2002-01-03 00:32:38 by Quantum
f0dder, that is very impressive. The FTP has full docs, and can't wait to browse the source code. SciTech is a nice group of people (I lived in Chico for five years, and met some of the people that worked there at the bars :)). They did some work on NASM, too.
Posted on 2002-01-03 01:14:09 by bitRAKE
Sorry for the wait... I was busy killing na*is in RTCW ;)

For the centering:

I guess so :( afaik for normal CreateWindow it is.

A Dialog on the other hand can get Centered using the
DS_CENTER (0x0800L) style.
Posted on 2002-01-03 02:25:04 by JimmyClif