CHOOSECOLOR structure

Posted By: RedPhoenix

CHOOSECOLOR structure - 09/01/07 10:44

You added the chooseColor function to the api list (api.def). But this function is senseless without having the CHOOSECOLOR structure. Please add the CHOOSECOLOR structure to the windows.h by default.

EDIT: Here the definitions:
Code:
  
typedef DWORD COLORREF; //unnecessary, but for being more similar to the msdn examples
typedef struct _CHOOSECOLOR{
long lStructSize;
long hwndOwner;
long hInstance;
COLORREF rgbResult;
COLORREF *lpCustColors;
long Flags;
long lCustData;
long lpfnHook;
char* lpTemplateName;
}CHOOSECOLOR;
DWORD __stdcall ChooseColor (DWORD);



And for dealing with the returned values there is also the need for these windows macros:
http://msdn2.microsoft.com/en-us/library/ms532645.aspx


P.S. You already included the flag definitions for this structure
Posted By: RedPhoenix

Re: CHOOSECOLOR structure - 09/01/07 21:37

Ok nevermind about the macros, I found a better solution:

Code:
 
typedef DWORD COLORREF; //unnecessary, but for being more similar to the msdn examples
typedef struct _CHOOSECOLOR{
long lStructSize;
long hwndOwner;
long hInstance;
char rgbResult[4];
COLORREF *lpCustColors;
long Flags;
long lCustData;
long lpfnHook;
char* lpTemplateName;
}CHOOSECOLOR;
DWORD __stdcall ChooseColor (DWORD); //function prototype



If the rgbResult member is defined as a char array, the bytes of the rgb value structure (0x00BBGGRR or sth. like that) will be seperated automatically. No need for the macro functions then.
Posted By: jcl

Re: CHOOSECOLOR structure - 09/03/07 08:34

Thanks for the suggestion. We'll add the CHOOSECOLOR struct and related defines and functions to the next version.
Posted By: yorisimo

Re: CHOOSECOLOR structure - 09/18/07 22:10

I am trying to use the ChooseColor function (i replaced my windows.h file with the new one from V7.06 beta that has the CHOOSECOLOR structure and function definition)
I get an "E1513 Crash in main" error when I try to run this:
Code:
 
#include <acknex.h>
#include <default.c>
#include <windows.h>

function main()
{
wait(1);

CHOOSECOLOR cc;
cc.lStructSize=sizeof(CHOOSECOLOR);
cc.hwndOwner=hWnd;
cc.hInstance=NULL;
cc.rgbResult=0x00aa0000;
cc.lpCustColors=NULL;
cc.Flags=CC_RGBINIT;
cc.lCustData=NULL;
cc.lpfnHook=NULL;
cc.lpTemplateName=NULL;

ChooseColor(&cc); //crashes here
}



Why?
Also when I try to use the RGB() macro, e.g, cc.rgbResult=RGB(0, 0, 0);, I get the error "machine code generator: can not translate CONV:CHAR::SHORT"
Posted By: RedPhoenix

Re: CHOOSECOLOR structure - 09/19/07 16:33

I don't know how conitec finally included the structure because I don't have the A7.06 beta, but if they did as I sugested above they won't have included the rgb macros, but defined the rgbresult as a byte array with 4 values. The rgba value will then be seperated automattically (it did in my code!).
You should check this in the windows.h, and then try it with the var type which they used for the rgbresult.
Posted By: yorisimo

Re: CHOOSECOLOR structure - 09/19/07 17:04

They didn't do it your way. This is what they added to windows.h:
Code:
 
typedef DWORD COLORREF;
typedef struct CHOOSECOLOR {
long lStructSize;
long hwndOwner;
long hInstance;
COLORREF rgbResult;
COLORREF *lpCustColors;
long Flags;
long lCustData;
long lpfnHook;
char* lpTemplateName;
} CHOOSECOLOR;

#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
#define GetRValue(rgb) ((BYTE)(rgb))
#define GetGValue(rgb) ((BYTE)(((WORD)(rgb)) >> 8))
#define GetBValue(rgb) ((BYTE)((rgb)>>16))

BOOL WINAPI ChooseColor(CHOOSECOLOR* lpcc);
#define PRAGMA_API ChooseColor;comdlg32.dll!ChooseColorA




I figured out my problem: lpCustColors cannot be null
© 2024 lite-C Forums