|
I'm not aware of any API. A good amount of the messages change meaning
depending on the window class of the recipient. The nearest to a cunning idea I have is to parse windows.h...
Tedious, admittedly.
Iain.
|
|
|
|
|
I used VC++6 a few years ago and then was out of programming for a long while. Trying to get back to it again (C++) using VS .Net 2003. Got a book (Step by step) where the author shows:
Console.Write(S"....");
What does the 'S' do? I've seen it with and without it and it seems to work the same either way. Where can I read about? I've tried looking in the .net help but I guess I'm not using the right search.
Thanks,
Jose
|
|
|
|
|
The S prefix on a string literal means "this is a managed Unicode string".
--Mike--
|
|
|
|
|
I get the string in each iteration of loop and i have to append that string at the end of file, but i am not getting the all values , file only shows(have) last written value in it.
I am using the code below:
CString text; //assume text var have different value in each iteration
For ( int i = 0 ; i <=5; i++)
{
CString filename = "f:/ TestFile.pc" ;
CFile files;
files.Open( filename , File::modeCreate|CFile::modeReadWrite|CFile::typeBinary);
files.Seek(0L,CFile::end);
files.Write(text , text.GetLength ());
//
files.Close ();
}
Regards.
|
|
|
|
|
|
First it was created by the code ,
Then after that want to append in already existing file.
So what Flags I should use, please tell me for writing 2nd time and so on
Regards.
|
|
|
|
|
|
Slight correction, Mike: RTFMSDN.
Software Zen: delete this;
|
|
|
|
|
The attribute File::modeCreate will cause the existing file to be truncated to a zero length every time you open it. So when you next Seek it won't do anything. You also need to open it with the attribute of File::NoTruncate.
Chris Meech
I am Canadian. [heard in a local bar]
When I want privacy, I'll close the bathroom door. [Stan Shannon]
BAD DAY FOR: Friendly competition, as Ford Motor Co. declared the employee parking lot at its truck plant in Dearborn, Mich., off limits to vehicles built by rival companies. Workers have to drive a Ford to work, or park across the street. [CNNMoney.com]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
Hi!
I'm trying to install my app on a computer where VS is not installed. For some reason it does not work. I tried to use depends.exe to find out where the problem is but I don't really know what to do with the results:
GetProcAddress(0x77BA0000 [MIDIMAP.DLL], "midMessage") called from "WINMM.DLL" at address 0x76AE3AFE and returned NULL. Error: Procedure cannot be found (127).
Second chance exception 0xE06D7363 (Microsoft C++ Exception) occurred in "KERNEL32.DLL" at address 0x7C81EB33.
Exited "VRSOFT20.EXE" (process 0x584) with code -529697949 (0xE06D7363).
Entrypoint reached. All implicit modules have been loaded.
The dll have the same version on both computers. What's wrong???
Luc
|
|
|
|
|
How can I rewrite
template < class Class1 > typedef friend class Class2;
so that it is compatible with .NET's compiler?
Any help is very appreciated.
-- modified at 12:28 Thursday 2nd February, 2006
|
|
|
|
|
Can any one please explain me how to change the the caption of a static control at run time based on some condition.For example during the OnInitDialog function of the dialog on which the control is there.
|
|
|
|
|
BOOL CMyDialog::OnInitDialog ()
{
SetDlgItemText (IDC_A_STATIC_TEXT, "New Text. Whoopidoo");
return CDialog::OnInitDialog ();
}
You have to give the static control an ID in the dialog editor, and ID_STATIC does not uniquely identify the control.
Iain.
|
|
|
|
|
Hey Guys,
Thanks a lot for you help. Exactly the same i was trying yesterday but that was not working i do not know why. I think ihad some problems.Thanks a lot again.
|
|
|
|
|
Use the SetWindowText function.
So if you have a static control with id IDC_STATIC1. Then you would change the text using:
<br />
GetDlgItem(IDC_STATIC1)->SetWindowText(_T("Ta Da!"));<br />
I Dream of Absolute Zero
|
|
|
|
|
Change IDC_STATIC to a unique name (IDC_MYSTATIC) and then go into the class wizard -> member variables -> select your static control -> Add member.
In the "Add member" dialog select CString and enter a name for your member variable, m_sMyStatic for example.
Now you can change the caption of the static control with
m_sMyStatic = "My new caption";
UpdateData (FALSE);
André
|
|
|
|
|
Hello everybody!
This site has helped me out in many ways many time, but now I can't find any hints on how to solve my problems. And I have three of them:
1. Status bar
I have added some additional text to the status bar (e.g. "Total data bytes received: %u"). I am connected to two com ports and receiving a lot of data. My problem is that the diplay of the status bar is only updated if I move the mouse !?! Do you have any ideas how to force an update or simply fix my problem?
2. Tool bar
I have a "Start/stop" button on the tool bar. At first it shows a green start icon. If I click on it it should change to a red stop icon. Any ideas how to do this easily with the standard mfc tool bar? My solution was to create another toolbar with all the same icons except the one start/stop button and load it completely, because you can't load single icons...
Another problem is, that the tool bar variable is defined in the MainFrame, but all my application stuff (including the menu action handlers...) is located in the view class. How can update the status bar from the view class? How can I get a pointer to the MainFrm class? I tryed it in many ways, but I only got some exceptions and other crashes
3. Invalid handle
I use an event based com port handler. There is a new thread for every com port. If a byte is received, the thread calls an EventHandler in one of my application classes. Sometimes if I click on disconnect or click very frequnently on the start/stop button, the program crashes with an invalid handler exception. I debugged it and traced down the problem to the thread call back function.
<br />
void Tserial_event_thread_start(void *arg)<br />
{<br />
class CComConnection *serial_unit;<br />
<br />
serial_unit = (CComConnection *) arg;<br />
<br />
if (serial_unit!=0)<br />
serial_unit->run();<br />
}<br />
What I found out is that sometimes "arg" is no valid pointer, but not a null pointer so the verification doesn't work. Within the run() method, a file (in fact it is the com port) is closed but because the object only contains garbage, the used handle is also garbage and causes an exception.
<br />
if (serial_handle!=INVALID_HANDLE_VALUE)<br />
CloseHandle(serial_handle);<br />
Is there any way to find out, if the handle is valid or not so I can just exit this function?
Thank you very much!
Jan Wedel
|
|
|
|
|
I'll try to address some of your problems... Just bare in mind I'm not on my development machine, so this if from memory.
0/ To get a pointer to your CMainFrame, just use CMainFrame *pMain = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd ()) .
Once you have that, you can get at any method you've exposed for changing toolbars / status bars, etc. Or use them as public members if you're brave / silly.
1/ Using (0), you could do pMain->m_barStatus.Invalidate (FALSE) to make the text refresh. But if you get a rush of data, your numbers could change annoyingly quickly. I'd change the value as you get data in, but have a timer updating the status bar from that value, rather than doing directly. And if you set the integer with one of the ::InterlockedXXXX functions, you have thread safety too.
2/ You *could* have a toolbar button changing, but that may not be necessary. Have a Play button (green arrow pointing right?). Add an OnUpdateUI handler in your view (look for ON_UPDATE_COMMAND macro). There, use pCmdUI->SetChecked (m_bImPlayingWheeeeee); to make the button sunken when playing, and not sunk when not playing. That should be more than sufficient, a lot easier to hook up, and flicker free.
3a/ If the handle is created from CreateFile, initialise and test against INVALID_HANDLE_VALUE, rather then 0 (You do set it to a value before you use it, don't you?). That was you only have one test, not too. More likely to be correct that way. The less work you do, the less mistakes you can make... That's my excuse for laziness, and I'm sticking to it.
3b/ You don't show your closing function, but after you close the handle, you should set it to INVALID_HANDLE_VALUE again. Then your tests work once more!
3c/ The above will work 99% of the time. But if you can access serial_handle from more than one thread, you need to wrap changes to it in EnterCriticalSection / LeaveCritical section. You can search for *lot* of examples.
I hoped that helped. If not, tough, as my fingers are tired out!
Good luck,
Iain.
|
|
|
|
|
Thanks!
I haven't try it, but your answers 0 + 1 should work for my problem!
answer 3a:
Yes the handle was created by CreateFile and as I posted before it is tested against INVALID_HANDLE_VALUE. I meant that the serial_unit object is tested against null. I debugged it and the handle has a value of somthing like 0xefffefff. The INVALID_HANDLE_VALUE is a defined constant not equal to that garbage handle in this case. And I set it to INVALID_HANDLE_VALUE after all CloseFile occurancies. The problem is, that the pointer is wrong so the object is filled with garbage data an so is the attribute serial_handle. I need to know how the CloseHandle function knows why the handle is invalid so I can avoid calling CloseHandle if the handle is invalid.
3c: I already use critical section with my handler, but the serial_handle is not static so there is no problem. Each thread has its own handle.
I know there must be another error concerning my pointer handling, but I really tried hard to debug and find it so I'm searchen for an alternative
Thanks!
|
|
|
|
|
I want to know that the files we use (ole32.lib kernerl*.lib ) like those system lib files are debug version lib files or build on release version ?
manu
|
|
|
|
|
|
I am developing an application where you can open multiple documents (data and log files) and for each document you can open up to 60 different views.
First i've limited it to one open document because multiple views of different documents on the same MDI workspace is not a good idea. This would also require that always at least one view is open for each document because otherwise it would be unclear which document receives the commands.
Now i've added a tabbed MDI interface to the app and misused it a little bit. Normally they are used to switch between single views of each document, what i'm doing now is hiding all views of the one document and show all for the other one. But i guess that might be confusing for the users.
My next idea would be multiple top level windows (main frames) which might be better and then one document per main frame and multiple views inside the MDI workspace.
I don't know any other app where you have multiple documents and multiple views. How have others solved this problem?
André
|
|
|
|
|
ABuenger wrote: This would also require that always at least one view is open for each document because otherwise it would be unclear which document receives the commands.
Using MFC ( I assume you are...? ), when the last view of a document closes, so does the document. Any commands go first to the active view, then to the document of the active view, then to the frame. So there should be no technical problem.
If you can hide all views of DocTypeX , and show all views of DocTypeY, then I would use two separate top level frames. That was the user has a well understood method of switching between them. Or can tile them next to each other, etc. Unless there is some *really* strong reason not to, I'd make them two separate applications - it'll make your coding simpler too.
Is there some reason for the two doc types living together? Does the data have an associated log file? If so, then maybe a modeless window which shows the log of the currently selected data doc? Your current-log-window can be docked, and the user switches between view / docs.
There are lots of ways to deal with the question, but the answers really depend on the details of what you are doing.
I hope this has given you some thinking ammunition an least!
Iain.
|
|
|
|
|
Iain Clarke wrote: Using MFC ( I assume you are...? ), when the last view of a document closes, so does the document. Any commands go first to the active view, then to the document of the active view, then to the frame. So there should be no technical problem.
Yes, i am using MFC, but i've disabled the auto-deletion of the document if the last view is closed because the user won't understand why he always has to have at least one of the 60 possible views open.
The app is used to tune engines, to be more precise, the engine control unit (ECU). The ECU has more than 100 settings, for cranking, for temperature/pressure/... changes.
Please click here for a screenshot[^]
You can make changes in realtime, while the engine in running. You can also monitor and log all engine parameters at the same time.
Now lets say you monitor and log data and you see knocking, so you turn off the engine, save the log and start analyze it. After you've made changes to the settings you go for a drive again and then you want to compare the two log files.
You may also want to open several data files and compare them and copy from one file to the other.
I also need some kind of splitter window, with a list of all settings on the left and then the views for data file 1 and data file 2 on the right. Differences between the two files should be highlited.
I've also tested to put a splitter window in the MDI client and then main frames (without menu and toolbars) inside each splitter, but i guess that's overkill.
André
|
|
|
|
|
Dear friends,
I would like to know what is Network Shutdowner. If any information regarding this issue, kindly give me a reply.
( any websites regarding this topics ) pls that also inform me.
Regards
kedar Bhagwat
Girish
Software Developer
|
|
|
|