Alright so I'm creating a C library to be used in RPG Maker XP or any other engine/program that wants to use it. Anyways I thought I'd experiment with windows.h a little and decided to try and create a method that when called brings up a better message box than rmxp's. It'll allow custom message, title, buttons, and icons. So I know how to convert the char* to the LPCSTRW but only if its in quotes L"Hi". However I am pretty clueless when its in a variable.
char *msg = "Hi there";
LPCWSTR rmsg = TEXT(msg);
// Results in an error
// error C2065: 'Lmsg' : undeclared identifier
I've tried this too.
LPCWSTR rmsg = (LPCWSTR)msg;
// Converts msg to weird japanese letters
Method
__declspec(dllexport) int MsgBox(char *msg, char *title, int b)
{
// Okay Button
int buttons = 0x00000000L;
switch (b)
{
case 0:
// Okay Button
buttons = 0x00000000L;
case 1:
// Yes No
buttons = 0x00000004L;
case 2:
// Yes No Cancel
buttons = 0x00000003L;
}
LPCWSTR rmsg = (LPCWSTR)msg;
LPCWSTR rtitle = (LPWSTR)title;
int r = MessageBox(0, rmsg, rtitle, buttons);
return r;
}
Any ideas?
You will have to use itoa for int, ftoa for float, etc. and then convert the char* into LPCSTRW. Or you can sprintf the variables.
Example please? D: I'm still learning C and C++ and whatnot.
"char* c = itoa(5)" I guess. Google it. You might want to use sprintf after all, I think that itoa isn't in the standard library. >.<
this (http://www.cprogramming.com/tutorial/lesson9.html) might help if you haven't resolved it yet
from what i can tell this is what you Are looking for
cout<<"Your long string was: "<< string <<endl;
string being the variable