This fails -> .if x >= 0 && x < ScreenWidth && y >= 0 && y < ScreenHeight
I found this: see next post
dibEngine(converted to assembly)
I can not post the link here , but one of the posters there ( that I know uses this a lot )posted this :
In the PutPixel procedure you'll need to put a check when the pixel is outside the canvas to not plot it. This can make the application crash because you're writting to memory outside the screen buffer:
SPixel PROC x:DWORD, y:DWORD, colour:DWORD
pushad
mov edi, [canvas_buffer]
.if x >= 0 && x < ScreenWidth && y >= 0 && y < ScreenHeight
mov eax,y
imul eax,ScreenWidth
add eax,x
shl eax,2
add edi,eax
mov eax,colour
mov dword ptr [edi],eax
.endif
popad
ret
SPixel endp
Here is a copy of the Original Post ( rather than linking that site )
Original Post:
Based off Wiccaan's dibEngine written for C++, just converted into assembly.
Still in beta.
Usage:
In a new project, with your other includes:
include dibEngine.inc
After creating your window:
invoke CreateWindowEx,0,addr lpclassname,addr lpwindowname,80000000h,100,100,400,300,0,0,esi,0 ;sample window
mov hwnd,eax
invoke dib_SetHwnd,hwnd
invoke dib_InitCanvas,400,300
Your lovely pallette is now all set for dib'ing. Now in either your main program loop(message processing), a WM_TIMER case, or, if the image is static, before the main game loop, you can make a series of calls to drawing functions - the current build includes dib_PutPixel, and dib_DrawButton:
invoke dib_PutPixel,100,100,0,0,255 ;x,y,r,g,b
invoke dib_DrawButton,200,200,offset lpclassname,0 ;x,y,text,bHover
Now in WM_PAINT:
invoke dib_UpdateCanvas
That's it! All you need to draw static pixels and buttons.;p
Just kidding, more support is on the way, but just wanted to release working code to show that I'm still alive.
A special thanks to Wiccaan, STN, and KSBunker, aswell as shoutouts to pandas and DeltronZero.
Attached is an example program, and the main dibEngine.inc file.
Demonstration of button-drawing:
(http://i133.photobucket.com/albums/q65/attilathedud/hacks/dib.jpg)
.if x >= 0 && x < ScreenWidth && y >= 0 && y < ScreenHeight
you are trying to compare one memory operand with another memory operand
the simplest way to fix this is to get "x" and "y" into registers
mov eax,y
mov ecx,x
.if (ecx>=0) && (ecx<ScreenWidth) && (eax>=0) && (eax<ScreenHeight)
imul eax,ScreenWidth
add eax,ecx
;
;
you could probably put ScreenWidth in EDX prior to the ".if" to create more efficient code
Thanks dedndave !
Well the original atachment works well
I have no idea why that poster recommended changing the set pixel proc to include a check
Now it does not draw pixels lol
this can be simplified
mov eax,y
mov ecx,x
mov edx,ScreenWidth
.if (ecx<edx) && (eax<ScreenHeight)
imul eax,edx
add eax,ecx
;
;
but i doubt that would stop it from drawing pixels
verify that ScreenWidth and ScreenHeight are set to valid values
I made those changes , but it won't draw ?
lol that one pixel is gone , and so is the button colour
Did you get it to work?
When I invoked the proc I invoked with 2 less variables and used a hex value for the colour instead of 3
The (r,b,g)
:(
this seems to work
dib_PutPixel proc x:DWORD, y:DWORD, r:BYTE, g:BYTE, b:BYTE
mov ecx,x
mov ebx,ScreenWidth
mov eax,y
.if (ecx<ebx)&&(eax<ScreenHeight)
imul eax,ebx
movzx ebx,byte ptr g
add eax,ecx
mov bh,r
shl ebx,8
mov ecx,lpCanvasBuffer
mov bl,b
mov [ecx+eax*4],ebx
.endif
ret
dib_PutPixel endp
EDX has to be preserved for some reason and EBX doesn't (i guess)
So you need to have r,b,g ......
Maybe that guy was messing with people ? ( I have seen some of the example he does no source)
I thought the change would be good if you can eliminate those and use hex colour
P.S
Is there an app that gives you an image's pixel coordinates + r,b,g for each pixel?
This guy does multi colour letters all plotted ????
no - you can use RGB
you will have to change the PROTO
and - you will have to change everyplace this function is used to pass an RGB
dib_PutPixel proc x:DWORD, y:DWORD, crRGB:COLORREF
mov ecx,x
mov ebx,ScreenWidth
mov eax,y
.if (ecx<ebx)&&(eax<ScreenHeight)
imul eax,ebx
add eax,ecx
mov ebx,crRGB
mov ecx,lpCanvasBuffer
mov [ecx+eax*4],ebx
.endif
ret
dib_PutPixel endp
if you have the colors as individual bytes in memory, you can use the RGB macro
otherwise, you can assign them as EQUates or something
COLORREF = 65536*Red + 256*Green + Blue
where Red, Green, and Blue are 0 to 255
Quote
COLORREF = 65536*Red + 256*Green + Blue
That reverses the order of the color components relative to the GDI RGB macro:
#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
void main()
{
BYTE r=1,g=2,b=3;
COLORREF rgb1, rgb2;
rgb1 = RGB(r,g,b);
rgb2 = 65536*r + 256*g + b;
printf("%Xh\n%Xh\n", rgb1, rgb2);
getch();
}
30201h
10203h
But duplicates the RGB component order for GDI+:
enum
{
AlphaShift = 24,
RedShift = 16,
GreenShift = 8,
BlueShift = 0
};
// Assemble A, R, G, B values into a 32-bit integer
static ARGB MakeARGB(IN BYTE a,
IN BYTE r,
IN BYTE g,
IN BYTE b)
{
return (((ARGB) (b) << BlueShift) |
((ARGB) (g) << GreenShift) |
((ARGB) (r) << RedShift) |
((ARGB) (a) << AlphaShift));
}
right, Michael - my mistake
those are RGBQUAD's, not COLORREF's
(well - modified versions of RGBQUAD's - lol)
Quote from: dedndave on February 01, 2013, 08:25:09 AM
no - you can use RGB
you will have to change the PROTO
and - you will have to change everyplace this function is used to pass an RGB
I meant the poster does not use r,g,b
His proto has colour : DWORD
So I assume he invokes set pixel with colour hex
What I said was that we can not use that, or can we?
That is what I tried with your first proc and it did not work....
This example is neat but I do not anticipate using it much
Unless there is an app that converts images to pixel coordinates
It would take for ever to plot image
There is a C example were I downloaded this but I don't get how they made it work
@MichaelW
I was actually looking on the net Today for a batch file to compile C
Do you know how? If so and you have time can you attach the above code with batch file to compile ?
I use batch files for masm all the time with notepad2 to edit and compile ,
Never found a C example
Thank you!
And sorry for asking
i would imagine you can use a command-line exe to compile with most C compilers
for microsoft, i think it's CL.EXE - you should be able to get the switches with /?
or look for it on MSDN
lol I know about CL there is also another batch file that sets the paths ...
I think this is it http://www.opensource.apple.com/source/awk/awk-18/src/vcvars32.bat
I can never get it to work .....
This is what I used for the above, but note that it depends on your having an appropriate PSDK installed:
set file="test"
set PATH=C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;%PATH%
set INCLUDE=C:\Program Files\Microsoft SDK\include;C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE%
set LIB=C:\Program Files\Microsoft SDK\lib;C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib;%LIB%
cl /W4 /Fa %file%.c
: cl /W4 /O2 /G6 /FA %file%.c
: cl /W4 %file%.c /link advapi32.lib
pause
Dave,
FWIW, the FreeBASIC developers see Microsoft's version as the mistake, renaming it in wingdi.bi to BGR:
#define BGR(r,g,b) (cuint(r) or (cuint(g) shl 8) or (cuint(b) shl 16))
Quote from: dedndave on February 01, 2013, 08:25:09 AM
no - you can use RGB
you will have to change the PROTO
and - you will have to change everyplace this function is used to pass an RGB
dib_PutPixel proc x:DWORD, y:DWORD, crRGB:COLORREF
mov ecx,x
mov ebx,ScreenWidth
mov eax,y
.if (ecx<ebx)&&(eax<ScreenHeight)
imul eax,ebx
add eax,ecx
mov ebx,crRGB
mov ecx,lpCanvasBuffer
mov [ecx+eax*4],ebx
.endif
ret
dib_PutPixel endp
if you have the colors as individual bytes in memory, you can use the RGB macro
otherwise, you can assign them as EQUates or something
COLORREF = 65536*Red + 256*Green + Blue
where Red, Green, and Blue are 0 to 255
How can I make this Proto work ?
@MichaelW
Thanks That bat Worked Geart :biggrin:
Here is a working link for: The Microsoft Visual C++ Toolkit 2003 If anybody wants it
http://kael.civfanatics.net/files/VCToolkitSetup.exe
And: Microsoft Platform SDK. For the windows.h and other includes and library's
http://kael.civfanatics.net/files/PSDK-x86.exe
HelloWorld.C
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
void main()
{
printf("Hello world!\n");
getch();
}
QuoteHow can I make this Proto work ?
well - that source is a bit of a mess - lol
some functions don't have a PROC
i didn't find any prototypes
but - if you declare a PROC before it is invoked, PROTO is not required
so - it does assemble and work
it would be much cleaner if all PROC's that have parameters were prototyped
prototypes typically go near the beginning of the source file, after the normal include/includelib's
speaking of which - the preamble is defined in both the asm source and the inc file
it should only appear in one or the other
as Michael mentioned, these are not COLORREF values, they are RGBQUAD's
however, COLORREF's are DWORDS, RGBQUAD's are 4-byte structures
i would change the PROC to look something like this
dib_PutPixel proc x:DWORD, y:DWORD, rgbColor:DWORD
then, near the beginning of the source, a prototype would be...
dib_PutPixel PROTO :DWORD, :DWORD, :DWORD
Quote from: dedndave on February 03, 2013, 12:35:39 AM
QuoteHow can I make this Proto work ?
as Michael mentioned, these are not COLORREF values, they are RGBQUAD's
however, COLORREF's are DWORDS, RGBQUAD's are 4-byte structures
Woops ....
I miss that .... I read it but did not quite understand that... I do now
I will stick to that first example that was converted to asm....
Quote from: dedndave on February 03, 2013, 12:35:39 AMthese are not COLORREF values, they are RGBQUAD's
however, COLORREF's are DWORDS, RGBQUAD's are 4-byte structures
I hear one senior assembler expert say "everything is a DWORD". Even 4-byte structures :biggrin:
i suppose the assembler will let you pass a structure as an atomic parameter
i have never tried it :P
i have already reached my quota of new things to try, this week - lol
Quote from: dedndave on February 03, 2013, 08:45:34 AM
i suppose the assembler will let you pass a structure as an atomic parameter
What do you mean with "atomic parameter"? Something like this?
include \masm32\include\masm32rt.inc
.code
rq RGBQUAD <12h, 34h, 56h, 78h>
testrc proc rcPar:RGBQUAD
movzx eax, rcPar.rgbRed
print hex$(eax), 9, "red", 13, 10
movzx eax, rcPar.rgbGreen
print hex$(eax), 9, "green", 13, 10
movzx eax, rcPar.rgbBlue
print hex$(eax), 9, "blue", 13, 10, 10
ret
testrc endp
start:
invoke testrc, rq
; invoke testrc, 78563412h ; works with JWasm but not with ML
inkey "bye"
exit
end start
Quoteworks with JWasm but not with ML
yes, that's exactly what i meant
maybe a misuse of terminology :P
i could probably force it to work with ASSUME or something - not worth the effort
maybe like this ?
ASSUME EDX:RGBQUAD
invoke testrc, edx
ASSUME EDX:Nothing
maybe this ?
invoke testrc, RGBQUAD ptr 78563412h
that doesn't seem right - lol
Quote from: dedndave on February 03, 2013, 09:06:18 AM
i could probably force it to work with ASSUME or something - not worth the effort
invoke testrc, rq
mov eax, offset rq
invoke testrc, RGBQUAD ptr [eax]
push 78563412h
invoke testrc, RGBQUAD ptr [esp]
mov eax, offset rq
assume eax:PTR RGBQUAD
invoke testrc, [eax]
All four variants work for ML and JWasm.
how about
invoke testrc, RGBQUAD ptr <12h,34h,56h,0>
i was trying to see how you'd do it with an immediate
In my test ML 6.15 had problems passing an RGBTRIPLE structure, but I think this could be due entirely to a longstanding bug with passing bytes on the stack. All of the other structures I tested could be accessed from the receiving procedure, so I assume they were passed correctly. I didn't have time for this, but it would be interesting to see if it can handle a very long structure with embedded structures, something like ENHMETAHEADER or DEVMODE.
;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================
.data
rgbt RGBTRIPLE <1,2,3>
align 4
aceh ACE_HEADER <1,2,3>
acl ACL <1,2,3,4,5>
align 4
rgbq RGBQUAD <1,2,3,4>
rectl RECTL <1,2,3,4>
bm BITMAP <1,2,3,4,5,6,7>
.code
;==============================================================================
Proc1 proc arg:RGBTRIPLE
printf("(%d)\t", SIZEOF arg)
movzx eax, arg.rgbtBlue
printf("%d\t", eax)
movzx eax, arg.rgbtGreen
printf("%d\t", eax)
movzx eax, arg.rgbtRed
printf("%d\n", eax)
ret
Proc1 endp
Proc2 proc arg:ACE_HEADER
printf("(%d)\t", SIZEOF arg)
movzx eax, arg.AceType
printf("%d\t", eax)
movzx eax, arg.AceFlags
printf("%d\t", eax)
movzx eax, arg.AceSize
printf("%d\n", eax)
ret
Proc2 endp
Proc3 proc arg:ACL
printf("(%d)\t", SIZEOF arg)
movzx eax, arg.AclRevision
printf("%d\t", eax)
movzx eax, arg.Sbz1
printf("%d\t", eax)
movzx eax, arg.AclSize
printf("%d\t", eax)
movzx eax, arg.AceCount
printf("%d\t", eax)
movzx eax, arg.Sbz2
printf("%d\n", eax)
ret
Proc3 endp
Proc4 proc arg:RGBQUAD
printf("(%d)\t", SIZEOF arg)
movzx eax, arg.rgbBlue
printf("%d\t", eax)
movzx eax, arg.rgbGreen
printf("%d\t", eax)
movzx eax, arg.rgbRed
printf("%d\t", eax)
movzx eax, arg.rgbReserved
printf("%d\n", eax)
ret
Proc4 endp
Proc5 proc arg:RECTL
printf("(%d)\t", SIZEOF arg)
printf("%d\t", arg.left)
printf("%d\t", arg.top)
printf("%d\t", arg.right)
printf("%d\n", arg.bottom)
ret
Proc5 endp
Proc6 proc arg:BITMAP
printf("(%d)\t", SIZEOF arg)
printf("%d\t", arg.bmType)
printf("%d\t", arg.bmWidth)
printf("%d\t", arg.bmHeight)
printf("%d\t", arg.bmWidthBytes)
movzx eax, arg.bmPlanes
printf("%d\t", eax)
movzx eax, arg.bmBitsPixel
printf("%d\t", eax)
printf("%d\n\n", arg.bmBits)
ret
Proc6 endp
;==============================================================================
start:
;==============================================================================
invoke Proc1, rgbt
invoke Proc2, aceh
invoke Proc3, acl
invoke Proc4, rgbq
invoke Proc5, rectl
invoke Proc6, bm
inkey
exit
;==============================================================================
end start
(3) 3 0 3
(4) 1 2 3
(8) 1 2 3 4 5
(4) 1 2 3 4
(16) 1 2 3 4
(24) 1 2 3 4 5 6 7
yah - but those are all memory operands
and, Jochen showed us how with registers
what about passing an immediate dword as a complete structure ?
I think it has to be a memory operand, and I see no way to do that with an immediate value in a single statement. This appears to work, but I think they will work only for the last argument:
mov eax, esp
printf("%d\n", eax)
push 04030201h
invoke Proc4, [esp]
mov eax, esp
printf("%d\n", eax)
mov eax, esp
printf("%d\n", eax)
push 04030201h
mov eax, esp
invoke Proc4, [eax]
mov eax, esp
printf("%d\n", eax)
Quote from: MichaelW on February 03, 2013, 03:06:14 PM
I think it has to be a memory operand, and I see no way to do that with an immediate value in a single statement.
JWasm can do it, and it's 4 bytes shorter:
push 78563412h
invoke testrc, RGBQUAD PTR [esp] ; workaround for ML using invoke
pop edx
invoke testrc, 78563412h ; direct - works with JWasm but not with ML
push 78563412h ; efficient workaround for ML
call testrc
For ML, push+call is the only way out.
Yes, the problem for ML appears to be the declared parameter type, in combination with the type checking, that according to some arguments I recall seeing, ML does not do :biggrin:
Proc7 proc arg:DWORD
push ebx
lea ebx, arg
ASSUME ebx:PTR RGBQUAD
printf("(%d)\t", SIZEOF arg)
movzx eax, [ebx].rgbBlue
printf("%d\t", eax)
movzx eax, [ebx].rgbGreen
printf("%d\t", eax)
movzx eax, [ebx].rgbRed
printf("%d\t", eax)
movzx eax, [ebx].rgbReserved
printf("%d\n", eax)
ASSUME ebx:NOTHING
pop ebx
ret
Proc7 endp
invoke Proc7, 04030201h
But it's more code, either way you go.
Quote from: MichaelW on February 03, 2013, 02:09:24 PM
In my test ML 6.15 had problems passing an RGBTRIPLE structure, but I think this could be due entirely to a longstanding bug with passing bytes on the stack. All of the other structures I tested could be accessed from the receiving procedure, so I assume they were passed correctly. I didn't have time for this, but it would be interesting to see if it can handle a very long structure with embedded structures, something like ENHMETAHEADER or DEVMODE.
;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================
.data
rgbt RGBTRIPLE <1,2,3>
align 4
aceh ACE_HEADER <1,2,3>
acl ACL <1,2,3,4,5>
align 4
rgbq RGBQUAD <1,2,3,4>
rectl RECTL <1,2,3,4>
bm BITMAP <1,2,3,4,5,6,7>
.code
;==============================================================================
Proc1 proc arg:RGBTRIPLE
printf("(%d)\t", SIZEOF arg)
movzx eax, arg.rgbtBlue
printf("%d\t", eax)
movzx eax, arg.rgbtGreen
printf("%d\t", eax)
movzx eax, arg.rgbtRed
printf("%d\n", eax)
ret
Proc1 endp
Proc2 proc arg:ACE_HEADER
printf("(%d)\t", SIZEOF arg)
movzx eax, arg.AceType
printf("%d\t", eax)
movzx eax, arg.AceFlags
printf("%d\t", eax)
movzx eax, arg.AceSize
printf("%d\n", eax)
ret
Proc2 endp
Proc3 proc arg:ACL
printf("(%d)\t", SIZEOF arg)
movzx eax, arg.AclRevision
printf("%d\t", eax)
movzx eax, arg.Sbz1
printf("%d\t", eax)
movzx eax, arg.AclSize
printf("%d\t", eax)
movzx eax, arg.AceCount
printf("%d\t", eax)
movzx eax, arg.Sbz2
printf("%d\n", eax)
ret
Proc3 endp
Proc4 proc arg:RGBQUAD
printf("(%d)\t", SIZEOF arg)
movzx eax, arg.rgbBlue
printf("%d\t", eax)
movzx eax, arg.rgbGreen
printf("%d\t", eax)
movzx eax, arg.rgbRed
printf("%d\t", eax)
movzx eax, arg.rgbReserved
printf("%d\n", eax)
ret
Proc4 endp
Proc5 proc arg:RECTL
printf("(%d)\t", SIZEOF arg)
printf("%d\t", arg.left)
printf("%d\t", arg.top)
printf("%d\t", arg.right)
printf("%d\n", arg.bottom)
ret
Proc5 endp
Proc6 proc arg:BITMAP
printf("(%d)\t", SIZEOF arg)
printf("%d\t", arg.bmType)
printf("%d\t", arg.bmWidth)
printf("%d\t", arg.bmHeight)
printf("%d\t", arg.bmWidthBytes)
movzx eax, arg.bmPlanes
printf("%d\t", eax)
movzx eax, arg.bmBitsPixel
printf("%d\t", eax)
printf("%d\n\n", arg.bmBits)
ret
Proc6 endp
;==============================================================================
start:
;==============================================================================
invoke Proc1, rgbt
invoke Proc2, aceh
invoke Proc3, acl
invoke Proc4, rgbq
invoke Proc5, rectl
invoke Proc6, bm
inkey
exit
;==============================================================================
end start
(3) 3 0 3
(4) 1 2 3
(8) 1 2 3 4 5
(4) 1 2 3 4
(16) 1 2 3 4
(24) 1 2 3 4 5 6 7
I con NOT compile this why ?
Error:
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: main.asm
main.asm(18) : error A2008: syntax error : (
main.asm(20) : error A2008: syntax error : (
main.asm(22) : error A2008: syntax error : (
main.asm(24) : error A2008: syntax error : (
main.asm(29) : error A2008: syntax error : (
main.asm(31) : error A2008: syntax error : (
main.asm(33) : error A2008: syntax error : (
main.asm(35) : error A2008: syntax error : (
main.asm(40) : error A2008: syntax error : (
main.asm(42) : error A2008: syntax error : (
main.asm(44) : error A2008: syntax error : (
main.asm(46) : error A2008: syntax error : (
main.asm(48) : error A2008: syntax error : (
main.asm(50) : error A2008: syntax error : (
main.asm(55) : error A2008: syntax error : (
main.asm(57) : error A2008: syntax error : (
main.asm(59) : error A2008: syntax error : (
main.asm(61) : error A2008: syntax error : (
main.asm(63) : error A2008: syntax error : (
main.asm(68) : error A2008: syntax error : (
main.asm(69) : error A2008: syntax error : printf
main.asm(70) : error A2008: syntax error : printf
main.asm(71) : error A2008: syntax error : printf
main.asm(72) : error A2008: syntax error : printf
main.asm(77) : error A2008: syntax error : (
main.asm(78) : error A2008: syntax error : printf
main.asm(79) : error A2008: syntax error : printf
main.asm(80) : error A2008: syntax error : printf
main.asm(81) : error A2008: syntax error : printf
main.asm(83) : error A2008: syntax error : (
main.asm(85) : error A2008: syntax error : (
main.asm(86) : error A2008: syntax error : printf
_
Assembly Error
Press any key to continue . . .
Hi Everbody:
You can get to the CL.EXE from C++ Microsoft 2008
Start C++
Tools
Command prompt
Regards herge
Quote from: MichaelW on February 01, 2013, 04:51:42 PM
This is what I used for the above, but note that it depends on your having an appropriate PSDK installed:
set file="test"
set PATH=C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;%PATH%
set INCLUDE=C:\Program Files\Microsoft SDK\include;C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE%
set LIB=C:\Program Files\Microsoft SDK\lib;C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib;%LIB%
cl /W4 /Fa %file%.c
: cl /W4 /O2 /G6 /FA %file%.c
: cl /W4 %file%.c /link advapi32.lib
pause
@MichaelW
I am sorry for asking , I know this is the masm forum and not C , but I can not get an answer anywhere!
If I want to add a resource file to that How do I do that?
Also I have used your Buid.Bat for C++ and I get an error but it still buids , Why?
The second example it will not build :biggrin:
Batch files are so plentyfull for masm but non that work for .c and .cpp
If you have time ....thank you!
I had no working examples to test, so I selected:
\Program Files\Microsoft SDK\Samples\multimedia\gdi\Fonts\FontView
And (eventually) I was able to build and link everything without error using this batch file:
set PATH=C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;C:\Program Files\Microsoft SDK\bin;C:\MASM32\bin;%PATH%
set INCLUDE=C:\Program Files\Microsoft SDK\include;C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE%
set LIB=C:\Program Files\Microsoft SDK\lib;C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib;%LIB%
cl /W4 /c fontview.c
pause
cl /W4 /c tools.c
pause
cl /W4 /c status.c
pause
cl /W4 /c dialogs.c
pause
cl /W4 /c display.c
pause
rc fontview.rc
pause
cvtres /MACHINE:IX86 /OUT:rsrc.obj fontview.res
pause
link fontview.obj tools.obj status.obj dialogs.obj display.obj rsrc.obj user32.lib gdi32.lib
pause
There are probably more compact/easier ways to do this (without nmake), but I went for individual command lines with pauses between them because I was expecting more errors than I encountered.
Note that cvtres.exe was not included with the PSDK or VC Toolkit 2003, and I could not see any way complete the build without it, so I used the copy in the MASM32\bin directory.
I have not done much C++, but here is a sampling of the command lines that I have used, successfully for at least most of them:
cl /c /FA /O2 /D "WIN32" /D "_CONSOLE" /ML /W4 /EHsc /TP test.cpp
cl /FA /O2 /D "WIN32" /D "_CONSOLE" /ML /W4 /EHsc /TP test.cpp
cl /c /FA /O2 /W4 /MD testlib.cpp /link EXPORT:Test /NODEFAULTLIB
cl /FA /O1 /ML /W4 /EHs /TP test.cpp
cl /FA /O2 /LD /D "WIN32" /D "_CONSOLE" /ML /W4 /EHsc /TP cinout.cpp
Thanks MichaelW
Still have trouble with one of the cpp but....
My original question to this thread ...I have found the full source and that code works ....
But the source is the graphics for a trainer , is that allowed ? even though there is no trainer stuff inside...
Cool graphics
Also I found out why I was getting the error:
: error LNK2019: unresolved external symbol __imp__MessageBoxA@16 refer
enced in function _WinMain@16
have to add :
#pragma comment(lib,"user32.lib");
under #include <windows.h>
So:
#include <windows.h>
#pragma comment(lib,"user32.lib"); :biggrin:
Quote from: MichaelW on February 06, 2013, 04:56:24 PM
Note that cvtres.exe was not included with the PSDK or VC Toolkit 2003, and I could not see any way complete the build without it, so I used the copy in the MASM32\bin directory.
I found cvtres.exe in PSDK(Microsoft Platform SDK) \bin\win64
Thank again MichaelW :greenclp:
:biggrin:
Here is another C example compiling exe and dll use Batch File :biggrin:
So now to try to compile some cpp with rsrc using batch file
I need a little help with this .cpp
I can not seem to ad the about dialog and the commands for the menu ...this should be straight forward :(
Lesson is included ...if anybody has time ...it is all compiled except those ...
745 AM going to bed
Thank You
To compile a CPP source I think your command line will need to include as a minimum /TP, /ML or /MD (or /MT if the app is multithreaded), and /EHsc or similar. I had to experiment with the options to determine what my app needed, and I probably included some that I did not need. Also, some of the command lines I posted were used to create libraries/DLLs. I use a batch file like this to get a short listing of the options for CL and LINK:
cl /? > clcmd.txt
link /? > linkcmd.txt
pause
I can build the DrawLite app with this batch file:
set PATH=C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;C:\Program Files\Microsoft SDK\bin;C:\MASM32\bin;%PATH%
set INCLUDE=C:\Program Files\Microsoft SDK\include;C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE%
set LIB=C:\Program Files\Microsoft SDK\lib;C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib;%LIB%
cl /c /ML /W4 /EHs /TP main.cpp
pause
cl /c /ML /W4 /EHs /TP MainWindow.cpp
pause
cl /c /ML /W4 /EHs /TP AboutDialog.cpp
pause
rc resource.rc
pause
cvtres /MACHINE:IX86 /OUT:rsrc.obj /MACHINE:IX86 resource.res
pause
link main.obj MainWindow.obj AboutDialog.obj rsrc.obj user32.lib gdi32.lib
pause
With a few warnings and no errors, but the window procedure in the MainWindow source does only the absolute minimum, so the app is mostly non-functional.
Note that I made no attempt to minimize the CL command lines.
Thank You MichaelW ! :biggrin:
I am still getting the same errors trying to add the menu functions and the about dialog...
So I am sure I am doing something wrong and it is not the Batch File
This is about all the time I want to spend on C++ The tut is included in my attachment , if any body know how to do that It would be great,
I am going back to Assembly :biggrin:
Yes I know this is childish, But I feel Better :P
P.S
change:
mov wc.hbrBackground,COLOR_BTNFACE+1
To
mov wc.hbrBackground, COLOR_WINDOW + 1
To get white face If you want