Click here to Skip to main content
15,921,959 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Making selected item bk 50% transparent in a ownerdrawn clistctrl Pin
Cris4-Jun-03 4:38
Cris4-Jun-03 4:38 
GeneralSpecial characters program Pin
meshteb3-Jun-03 21:35
meshteb3-Jun-03 21:35 
GeneralRe: Special characters program Pin
Ted Ferenc3-Jun-03 21:55
Ted Ferenc3-Jun-03 21:55 
GeneralRe: Special characters program Pin
Andrew Walker3-Jun-03 22:03
Andrew Walker3-Jun-03 22:03 
GeneralConverting _int64 to string Pin
Shah Shehpori3-Jun-03 21:04
sussShah Shehpori3-Jun-03 21:04 
GeneralRe: Converting _int64 to string Pin
askadar3-Jun-03 21:50
askadar3-Jun-03 21:50 
GeneralRe: Converting _int64 to string Pin
Mike Nordell4-Jun-03 3:31
Mike Nordell4-Jun-03 3:31 
GeneralMessage and Single Instance Pin
Rage3-Jun-03 20:49
professionalRage3-Jun-03 20:49 
Hi CPians !

My MFC Dialog app needs to be runned single under NT/XP. To that end I use PJNaughter's single instance which works very fine. I have associated some config files to my app, so that when the user double clicks on them, my app is opened. So far so good.
If my app is already running when the user double clicks on a cfg file, I'd like to send a message from the second instance to the first with the name of the file to open in it, so that i can open the config file in the first, and kill the second.
BUT I can't get this to work.

I use a registered message, which is arriving properly and handled properly with ON_REGISTER_MESSAGE, but I can't retrieve the sent string. :

App2 (which is to be terminated) :

CString Filename="C:\\Myfile.cfg";
::SendMessage(WM_USER_2NDOPEN,(WPARAM)(Filename.operator LPCTSTR()),0);


App1 (which should process the message :

LPCTSTR buff;
buff=(LPCTSTR)wParam;


won't work. I have tried about everything, using LPSTR, LPCSTR, LPTSTR, LPCTSTR (so Unicode and not Unicode), even a CString, or a char[1024] or a char * (I know some of these solutions are redundant) passing each time the address of the string to the first app, and tried every possible configuration of typecasts in the receiving function, but I can't seem to retrieve the sent string (most time, when the casts make sense, I have "IIIIIIIIIIIIIIIIIIIIIIIIIIIIII..." in the buff). And the Send instead of Post makes sure the string does not get destroyed before I read it from memory.

The weirdest thing is that if I replace the CString, or the LPCTSTR or what in the App2 with :

::SendMessage(WM_USER_2NDOPEN,(WPARAM)"RaGE",0);


Then I can retrieve the string without any problem, whatever the format and typecast I use in the receiving function in App1. Eek! | :eek:

My temporary solution is that I save the filename in a text file on the disk in C:\\Temp in App2, send the message and retrieve the name by reading it frim the file in App1. But I think this solution really sucks. Roll eyes | :rolleyes:

I'd like to do it the right way, and I'm sure it _is_ possible to send a string using a windows message...

Can you help me ?



~RaGE();
GeneralChanging tooltips at runtime for a CWnd object Pin
Raghunandan S3-Jun-03 19:32
Raghunandan S3-Jun-03 19:32 
GeneralRe: Changing tooltips at runtime for a CWnd object Pin
oz_the_wizard3-Jun-03 21:58
oz_the_wizard3-Jun-03 21:58 
GeneralDeletePrinter() don't work...Please advise me... Pin
charisma_youn3-Jun-03 19:13
charisma_youn3-Jun-03 19:13 
GeneralMake Program in VC++ to send E-mail Pin
Anonymous3-Jun-03 18:29
Anonymous3-Jun-03 18:29 
GeneralRe: Make Program in VC++ to send E-mail Pin
valikac3-Jun-03 19:30
valikac3-Jun-03 19:30 
GeneralRe: Make Program in VC++ to send E-mail Pin
Anonymous3-Jun-03 22:53
Anonymous3-Jun-03 22:53 
GeneralRe: Make Program in VC++ to send E-mail Pin
valikac4-Jun-03 7:14
valikac4-Jun-03 7:14 
GeneralRe: Make Program in VC++ to send E-mail Pin
Axter3-Jun-03 21:06
professionalAxter3-Jun-03 21:06 
GeneralVC.NET in multiprocessor station Pin
Stormwind3-Jun-03 17:30
Stormwind3-Jun-03 17:30 
GeneralRe: VC.NET in multiprocessor station Pin
Mike Nordell4-Jun-03 3:32
Mike Nordell4-Jun-03 3:32 
Generala problem on Installshield for VC++ Pin
olinn3-Jun-03 17:23
olinn3-Jun-03 17:23 
GeneralWhy don't run the same programe code on vc++ compiler Pin
tomjacksun3-Jun-03 16:59
tomjacksun3-Jun-03 16:59 
GeneralRe: Why don't run the same programe code on vc++ compiler Pin
Christian Graus3-Jun-03 17:06
protectorChristian Graus3-Jun-03 17:06 
GeneralRe: Why don't run the same programe code on vc++ compiler Pin
sunjohn3-Jun-03 17:15
sunjohn3-Jun-03 17:15 
GeneralRe: Why don't run the same programe code on vc++ compiler Pin
Christian Graus3-Jun-03 17:17
protectorChristian Graus3-Jun-03 17:17 
GeneralRe: Why don't run the same programe code on vc++ compiler Pin
tomjacksun3-Jun-03 17:45
tomjacksun3-Jun-03 17:45 
GeneralRe: Why don't run the same programe code on vc++ compiler Pin
Christian Graus3-Jun-03 17:49
protectorChristian Graus3-Jun-03 17:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.