call() with dialogs? [edit] in Developer Help
|
|
Code:
char *rgb(COLORREF rgbVal) { int r = GetRValue(rgbVal), g = GetGValue(rgbVal), b = GetBValue(rgbVal); int rHi = r & 0x0F, gHi = g & 0x0F, bHi = b & 0x0F; int rLo = r >> 4, gLo = g >> 4, bLo = b >> 4; char *returnVal = new char[8];
returnVal[0] = '#'; returnVal[1] = (unsigned char)(rLo<10 ? rLo+48 : rLo+55); returnVal[2] = (unsigned char)(rHi<10 ? rHi+48 : rHi+55); returnVal[3] = (unsigned char)(gLo<10 ? gLo+48 : gLo+55); returnVal[4] = (unsigned char)(gHi<10 ? gHi+48 : gHi+55); returnVal[5] = (unsigned char)(bLo<10 ? bLo+48 : bLo+55); returnVal[6] = (unsigned char)(bHi<10 ? bHi+48 : bHi+55); returnVal[7] = '\0'; return returnVal; }
extern "C" __declspec(dllexport) char *byond_ChooseColor(int n, char *v[]) { CHOOSECOLOR cc; ::ZeroMemory(&cc, sizeof(cc)); cc.lStructSize = sizeof(cc); cc.Flags = CC_PREVENTFULLOPEN;
if(::ChooseColor(&cc)) return rgb(cc.rgbResult); else return 0; }
|
client/verb/Test() src << call("byond_choosecolor.dll", "byond_ChooseColor")()
|
Problem description:
I thought it would be neat to use a common Windows dialog box to select a color. The above was my initial attempt at it, but it doesn't really work. In fact, nothing happens after I execute the verb and allow access to the DLL---until I take focus from the Dream Seeker window, which causes Dream Seeker to crash abruptly. Is there something I'm missing out on entirely that's causing a major crash here, or is what I'm trying just not feasible?
I've uploaded the DLL itself temporarily here, so that you don't have to compile your own to test the above result if you can't or don't want to. Thanks in advance!
Edit: For some reason, I had some funky logic in the rgb() function. Fixed it, I think. Problem still stands with the crashing, though. :S
Hiead
|
I could be wrong...