Sign in to follow this  
Promethium

Need some help with MAKE_STRING

Recommended Posts

Good day peopleI have been working on a number a C++ gauges for an aircraft project i am working on. So far i have been able to get everything working with the search function in this forum :) the Dragonflight Design tutorial and the SDK (god help me). But finally i have come to a sticky spot, i have started working on the radio stack, i can do all the frequency changes turn stuff on and off and all that but for the life of me a can't get a handle in displaying a string with MAKE_STRING. Heres the code i have all i wont it to do is display "hello" (now it that so hard) once i get it working i should be able to do what i wontMAKE_STRING( string_speed, NULL, NULL, IMAGE_USE_ERASE | IMAGE_USE_BRIGHT, 0, 142,12, 151,63, 5, MODULE_VAR_NONE , MODULE_VAR_NONE, MODULE_VAR_NONE, RGB(255,0,0), RGB(0,0,0), RGB(00,00,00), GAUGE_FONT_DEFAULT, GAUGE_WEIGHT_DEFAULT, GAUGE_CHARSET, 0, DT_SINGLELINE, NULL, STRING_cb)FLOAT64 FSAPI STRING_cb( PELEMENT_STRING pelement ){FLOAT64 val=pelement->source_var[0].var_value.n;val = !val; wsprintf(pelement->string, "%5s", "HELLO"); // return val;}now the problem i am having is that if i try and compile the i get:"error C2664: 'wsprintfW' : cannot convert parameter 1 from 'PCHAR' to 'LPWSTR'Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"If i try and use "sprintf(pelement->string, "%5s", "HELLO");"i get "error C3861: 'sprintf': identifier not found" I tried to compile the temperature gauge from the SDK and i get the same sorts of errors, so its not that nothing is displayed i cant even get it to compile (i'm using Visual C++ 2008 Express Edition) as far as i can tell i have included all of the necessary headers and what not and i have tried code snipits for every ware but nothing works.Any help on this would be greatly appreciatedCheersPaul

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Try:FLOAT64 FSAPI STRING_cb( PELEMENT_STRING pelement ){FLOAT64 val=pelement->source_var<0>.var_value.n;val = !val;wsprintf(pelement->string, (LPWSTR)"%5s", (LPWSTR)"HELLO"); // return val;}

Share this post


Link to post
Share on other sites

HiThanks for the reply, i tried the modified callback but to no successes i still get the same "can't convert" error and a new "error C2059: syntax error : '.'"i have had this error before but i don't have enough knowledge to diagnose the problem. I have only just started to learn C++ :) (good way to start i thing :( )CheersPaul

Share this post


Link to post
Share on other sites

>>"error C2664: 'wsprintfW' : cannot convert parameter 1 from>'PCHAR' to 'LPWSTR'>Types pointed to are unrelated; conversion requires>reinterpret_cast, C-style cast or function-style cast">>Are you compiling with UNICODE as the character set? If so, then you can't use the wide version because of conversion troubles. In this case you should use 'sprintf'.>If i try and use "sprintf(pelement->string, "%5s", "HELLO");">i get "error C3861: 'sprintf': identifier not found" >#include in your header.Tom

Share this post


Link to post
Share on other sites

Included the stdio.h file into the header and WWOOO HHOO it compiled yaaaaa. However now i just get a blank display in FS :( but thats ok now at least i know it will compile and its just a case of messing with it till it works. if i can't get it working i will post a new question :) . Thanks for your help Ed and Tom i have been beating my head against the keyboard for two days on this one now i might get someware.Tom are there any other header file that you might suggest including to prevent this kind of thing.Cheers and thanks againHave funPaul

Share this post


Link to post
Share on other sites

>Tom are there any other header file that you might suggest including to prevent this kind of thing.The best is to include only those necessaries for the project. Besides, in VC++ Express 2005/8 it's rather simple to figure out which one is missing:-when a certain function fails to compile ie "xxxfunct: identifier not found", just open the VC++ help window, search for function's name (C++ version), and check out at the bottom of the page which libraries/includes are needed.>P.S. i don't know if its UNICODE how would i find out?Enter in VC Project Properties -> Configuration Properties -> General -> Character set. Default is "Not set". Other are "Unicode" and "Multi-byte". Default should be OK.Or maybe you're using "nmake" makefile to compile? You may want to search in http://forums.flightsim.com/vbfs/forumdisplay.php?f=24 to see some of Bill's examples on how to configure VC++ Express for FS gauges' bulding.Tom

Share this post


Link to post
Share on other sites

Good day peoplei had a look in the properties and I was indeed using UNICODE i reset it to "Not set" as you described and woo hoo it worked i have a string from the SDK.Temperature example working on my gauge its now just a matter of messing with it till i get what i wont. Thanks heaps guys ur bloody legends, this C++ caper has been a huge leaning curve but i can see how you can get hooked when somthing works the way it should :)Thanks for for the help and adviceHave funPaul

Share this post


Link to post
Share on other sites

Hey oThe ultimate goal of this exercise was too display the NAV and COM frequency's for the radio stack. Well getting something, anything to display was the first half of the battle and with your help i got there.Well just to show that it hasen't all gone to waste. :) Heres my code for displaying the NAV1 standby frequency (which i can change with my newly codded buttons :) )FLOAT64 val = 0; // first declare the float C variableFLOAT64 FSAPI string_cb( PELEMENT_STRING pelement ){ execute_calculator_code("(A:NAV STANDBY FREQUENCY:1, MHz)",&val,NULL,NULL); sprintf( pelement->string, "%6.2f", val ); return 0;}//////////////////////////////////MAKE_STRING( temperature_string, NULL, NULL, IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY, 0, 142, 12, 60, 29, 6, MODULE_VAR_NONE, MODULE_VAR_NONE, MODULE_VAR_NONE, RGB(255,0,0), RGB(0,0,0), RGB(92,92,92), GAUGE_FONT_DEFAULT, GAUGE_WEIGHT_DEFAULT, GAUGE_CHARSET, 0, DT_CENTER | DT_VCENTER | DT_SINGLELINE, NULL, string_cb)PELEMENT_HEADER TEST_plist1[] ={ &temperature_string.header, NULL}; Works a treat thanks guysHave fun peoplesPaul

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this