So I decided to use a choosecolor dialog box, mind you im using the newest headers from the goasm headers project. Here is my code, It doesnt give me any errors but when i click the button for it to show the colors dialog box it causes the program to exit with error.
DATA SECTION
cColor CHOOSECOLORA <?> ; I have to choose CHOOSECOLORA or CHOOSECOLORW, or is it gives me a error.
............. The usual code here .....................
cmp d[uMsg],WM_COMMAND
jne >TRUE
cmp d[uMsg],IDC_CHOOSECOLORS
jne >FALSE
invoke ZeroMemory,addr cColor,sizeof(cColor)
mov d[cColor.lStructSize],sizeof(cColor)
push [hWnd]
pop [cColor.hwndOwner]
mov d[cColor.Flags],CC_PREVENTFULLOPEN
invoke ChooseColor,addr cColor
jmp >TRUE
Im guessing it has to do with how the structure was defined in the headers? or am I doing something wrong here?
EDIT: Sorry for the double post, internet is REALLY slow..
Even just tried creating a project by itself for it and it still errors :S Any thoughts?
jne >TRUE
definately looks wrong to me
TRUE and FALSE are definitions, NOT labels
As you have just been told, TRUE and FALSE should NOT be used as they will cause a brane to the value contained in them which is 1 or 0. Definitely not a good idea to redirect program execution to either of those addresses.
Paul
Well the labels arnt actually true and false but they lead to
xor eax,eax
ret
and
mov eax,1
ret
They have to divert flow for the dialog procedure to return true or false because there is no conditional assembly statements like if and then in goasm. :S unless im missing something here?
What they are saying is that you must change the names of your LABELS to something other than TRUE or FALSE.
Oh I kinda thought that, I just put true or false to show what they were leading to sorry for that. I didn't know you HAVE to fill out the custom colors part of the structure so now it works... but it doesnt return an rgb value? what does the type return?
cColor.rgbResult contains the color selected if they exit with OK (returns nonzero). It is of the form 0x00bbggrr.
Regards,
Darrel
Im trying to write the results to a ini file but its just erasing the value:
invoke WritePrivateProfileString,addr IniKey,addr IniString,addr cColor.rgbResult,addr IniFile
doing something wrong?
Someone else can correct me if I'm wrong, but I believe you need to convert DWORD (CColor.rgbResult) to a string.
Ahh kind of figured that, I wish goasm had dwtoa, can't remember having to do this is there a easy way to do it?
DWORD_to_ASCII PROC dword0:DWORD,lpsz:DWORD
LOCAL tempbuffer[16]:BYTE
LOCAL dw10:DWORD
LOCAL posneg:BYTE
mov dw10,10
mov eax,dword0
xor ecx,ecx
or eax,eax
jns DWORD_to_ASCII_00000
neg eax
inc ecx
DWORD_to_ASCII_00000:
mov posneg,cl
push ebx
push edi
mov ebx,lpsz
lea edi,tempbuffer
xor ecx,ecx
DWORD_to_ASCII_00001:
xor edx,edx
div dw10
or dl,30h
mov BYTE PTR[edi+ecx],dl
inc ecx
or eax,eax
jnz DWORD_to_ASCII_00001
cmp posneg,0
je DWORD_to_ASCII_00002
mov BYTE PTR[ebx+eax],02Dh
inc eax
DWORD_to_ASCII_00002:
dec ecx
mov dl,BYTE PTR[edi+ecx]
mov BYTE PTR[ebx+eax],dl
inc eax
or ecx,ecx
jnz DWORD_to_ASCII_00002
mov BYTE PTR[ebx+eax],0
pop edi
pop ebx
ret
DWORD_to_ASCII ENDP
No need to convert anything, use WritePrivateProfileStruct instead to write raw data to an INI file...
invoke WritePrivateProfileStruct, addr Section, addr IniKey, addr cColor.rgbResult, SIZEOF CHOOSECOLOR.rgbResult, addr IniFile
Quote from: travism on May 18, 2009, 05:54:59 AM
Ahh kind of figured that, I wish goasm had dwtoa, can't remember having to do this is there a easy way to do it?
It is apparently impolite to discuss GoAsm related questions in this forum...
Quote
It is apparently impolite to discuss GoAsm related questions in this forum...
Oh my bad thought it was a "general assembler" forum... :-\ Thanks for the help :)
Edit: btw donkey it worked perfectly. :)
I'm replying a late because i guess it might be important if someone else sees this topic. You definatelly need the 16*COLORREF array. I've experienced similar problems.
ClrRefs dd 0ff0000h,0ff00h,0ffh,0ffff00h,0ffffh
dd 0cc0000h,0cc00h,0cch,0cccc00h,0cccch
dd 0800000h,08000h,080h,0808000h,08080h
dd 0400000h
Thanks and bye
i got this table from MichaelW
it emulates the old CGA 16 color set, and thus, the first 16 default EGA/VGA values
CustomColors dd 00000000h,00AA0000h,0000AA00h,00AAAA00h
dd 000000AAh,00AA00AAh,000055AAh,00AAAAAAh
dd 00555555h,00FF5555h,0055FF55h,00FFFF55h
dd 005555FFh,00FF55FFh,0055FFFFh,00FFFFFFh
Thanks dave. That's something i didnt know. Ty and bye