|
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
|
|
|
|
|
vcforums wrote: I would like to know what is Network Shutdowner.
Given the capitalization, I suspect it is the name of an application. Is this something that you have seen, used, or just heard about?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Hi
How does the one dynamicly allocate some CDialog and some controles wich are also allocated, and where do I set position on say like CButton?
TNX
|
|
|
|
|
|
Hi,
I send SB_THUMBTRACK with WM_VSCROLL message to ListCtrl, but ListCtrl does not respond to it. But same to a TreeCtrl does not make any problem.
Do anybody know why?
- NS -
|
|
|
|
|
Sending SB_THUMBTRACK, SB_THUMBPOSITION, SB_ENDSCROLL messages will not work for CListCtrl in Win2K and XP. These messages will works only in 95/98 and ME. I believe the problem is with implementation of some Win32 API functions for different versions of Windows.
You can probably try this alternative...
Call CListCtrl::Scroll with the X and Y coordinates.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Oh I see...
Could you tell me the reason?
- NS -
|
|
|
|
|
NS17 wrote: I send SB_THUMBTRACK with WM_VSCROLL message to ListCtrl, but ListCtrl does not respond to it.
What does the call to SendMessage() look like?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
List controls do not respond to WM_HSCROLL or WM_VSCROLL messages. They use their own LVM_SCROLL message.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I use a custom scrollbar derived from CWnd. This scrollbar can send WM_VSCROLL message to the list control directly, because the list control window handle is with the scrollbar. All other messages except SB_THUMBTRACK can be processed by the list control. But this same for tree control is working fine.
Then what could be the best solution for this problem?
Thank you.
- NS -
|
|
|
|
|
hai,
I m having a problem with msxml2.lib in debug mode compilation. Its just puzzling me. I installed xml sdk3.0 version in my system. when i tried to compile a simple code in vc++ 6.0( Just com object creation of xmldomdocument )
i got this error "msxml2.lib(msxml2_i.obj) : fatal error LNK1103: debugging information corrupt; recompile module
Error executing link.exe"
I had included msxml2.h , msxml2.lib in library options also. I am having visual studio 6.0.
Can anyone give suggestions for this, i need to call those apis in debug mode only.
Advanced thanks for giving any kind of suggestion
manu
|
|
|
|
|
I'm pretty sure the last version of the Platform SDK compatible with VC6 was Feb 2003.
The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison
Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
Hi!
I have a problem with dll programming. I am programming dll's for the micorosft flightsimulator.
Anyway in DEBUG mode i have the strange problem that i get a assertion in ntdll.dll telling me that a incorrect adress is passed to RtlFreeHeap when the sim wants to unload my module...so the problem is only on closing my dll. The error occours in the fs9.exe and not in my dll but i pass many (correct) pointers to the exe of course and its working with them.
I had found that the invalid adress that is passed to the RtlFreeHeap function is a pointer to a constant character string "xxxxxx" located in the .rdata section of my dll. When i remove the constant for my code the problem is still present but points to antoher adress also somewhere in the .rdata area of my dll.
Has anybody a idea what could be wrong with my heap setup and/or dll compilation that causes a problem with my .rdata memory area. Is there maybe something that i do not know about constants in dll's or resources in dlls.
My dll needs much memory, but still in the minimal configuration the error is present.
Again the problem is only on closing where the fs9.exe wants to free my memory? ans is not present during normal operation. Additional i could find that error when compiling in release mode.
Is there somewhere a tutorial about "do nots" in dll code programming...
hope somebody can help me
regards
Florian
|
|
|
|