DesideriusPapp
New member
- Joined
- May 23, 2009
- Messages
- 21
- Reaction score
- 0
- Points
- 0
Hi all,
I'm working on a spacecraft with a .dll. I'm a complete C++ noob, and using VC++ 2008 express edition. I'm trying to put toghether a VC and am currently busy with standard MFD's.
I got to the point of correctly displaying the MFD's and making buttons work - now I'm stuck with the redraw of labels. Here's the code:
I derived it from the OrbiterSDK API Guide and the code samples that come along with it (DG and ShuttleA). The point is that when I try and compile I get the following compiling error:
1>.\Strelka.cpp(134) : error C2664: 'TextOutW' : cannot convert parameter 4 from 'const char *' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Some Google told me that the point lies in the charachter set (UNICODE or ANSI), thus I tried changing the configuration properties of my project from [Use Unicode Charachter Set] to [Use Multi-Byte Charachter Set]. The code compiles but I get a CTD if I try to switch to VC. Same result by keeping [Use Unicode...] and changing the line
TextOut (hDC, 5, 2+20*bt, label, strlen(label));
to
TextOut (hDC, 5, 2+20*bt, (LPCWSTR) label, strlen(label));
i.e.: it compiles, but I get a CTD when going to VC.
Some more Google pointed me to functions that perform the seemingly required conversion, but I find no trace of this in any of the Orbiter sample code, and noone else in the forum seems to have had the same problem, so I thought there might be a simpler solution - as I'm not quite sure how to implement these conversion functions.
A bit more of information that could be helpful: I'm using a texture for MFD and a different texture for buttons, which is flagged for Decompression.
Anyone can help?
Thank you,
I'm working on a spacecraft with a .dll. I'm a complete C++ noob, and using VC++ 2008 express edition. I'm trying to put toghether a VC and am currently busy with standard MFD's.
I got to the point of correctly displaying the MFD's and making buttons work - now I'm stuck with the redraw of labels. Here's the code:
Code:
bool Strelka::clbkVCRedrawEvent(int id, int event, SURFHANDLE surf)
{
int bt;
const char *label;
switch (id)
{
case AID_MFD_R_LEFT:
hDC = oapiGetDC (surf);
for (bt = 0; bt<6; bt++)
{
if (label = oapiMFDButtonLabel (MFD_RIGHT, bt))
TextOut (hDC, 5, 2+20*bt, label, strlen(label));
else break;
};
case AID_MFD_R_RIGHT:
return true;
};
oapiReleaseDC (surf, hDC);
return true;
}
I derived it from the OrbiterSDK API Guide and the code samples that come along with it (DG and ShuttleA). The point is that when I try and compile I get the following compiling error:
1>.\Strelka.cpp(134) : error C2664: 'TextOutW' : cannot convert parameter 4 from 'const char *' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Some Google told me that the point lies in the charachter set (UNICODE or ANSI), thus I tried changing the configuration properties of my project from [Use Unicode Charachter Set] to [Use Multi-Byte Charachter Set]. The code compiles but I get a CTD if I try to switch to VC. Same result by keeping [Use Unicode...] and changing the line
TextOut (hDC, 5, 2+20*bt, label, strlen(label));
to
TextOut (hDC, 5, 2+20*bt, (LPCWSTR) label, strlen(label));
i.e.: it compiles, but I get a CTD when going to VC.
Some more Google pointed me to functions that perform the seemingly required conversion, but I find no trace of this in any of the Orbiter sample code, and noone else in the forum seems to have had the same problem, so I thought there might be a simpler solution - as I'm not quite sure how to implement these conversion functions.
A bit more of information that could be helpful: I'm using a texture for MFD and a different texture for buttons, which is flagged for Decompression.
Anyone can help?
Thank you,