|
Hi there ,
I GOT A SIMPLE PROBLEM.I AM COMPILING A VC++ ( 5.0 ) PROGRAM WHERE I AM HAVING A DIALOG BOX APPLICATION.IN THE DIALOG BOX I AM HAVING A EDIT BOX WHER5E I WISH TO DISPLAY THE VALUE OF THE ITERATION COUNT IN THIS EDIT BOX . SIMPLE !!!
THE CODE I HAVE WRITTEN ON MOUSE CLICK OF A PUSH BUTTON IS AS FOLLOWS.
:: OnPress()
{
for ( int i=0;i<10;i++)
{
m_number=i;
UpdateData (FALSE );
Sleep( 1000 );
}
}
m_number is variable associated with the edit box and is integer type.When i run the program only last count i.e 9 is displayed in the edit box.why not all count is displayed in the edit box?
Can somebody please guide me?Why this is happening.
Thanks in advance.
Lets share our knowledge and make this world even more beautiful.
|
|
|
|
|
I believe it has to do with your calls to the Sleep() function. The sleep function was not realy meant to be used in this maner. What the sleep function does is suspend the execution of your current thread. So your edit box wont even have time to update itself before the sleep starts... or even after. I imagine the only thing displayed in you edit box, after 9 seconds, is 9.
I'd recomend looking at using a timer, and update the edit box with that.
-Ben
"Its funny when you stop doing things not because they’re wrong, but because you might get caught." - Unknown
|
|
|
|
|
Think : "Message pump". I do not believe that UpdateData forces messages to be processed for the windows in question, thus your edit window is not refreshed until you fall out what ever message handler you are in. In other words, the message pump is suspended while your loop is processing thus the window you wish to display the result in never recieves the message to update itself with the value. You will need to force the message pump to run from within your loop.
Try adding a method like this to your dialog, and call it from within your for loop:
BOOL
CFWThumbsDlg::ProcessMessageQue()
{
MSG msg;
while( ::PeekMessage((LPMSG) &msg, (HWND) NULL, 0, 0, PM_REMOVE ))
{
TranslateMessage((LPMSG) &msg);
DispatchMessage((LPMSG) &msg);
}
return( TRUE );
}
|
|
|
|
|
Hi.
Your code would be right for a console (or DOS) app, which is run as a sequence.
As mentioned above, you block the message pump, because you do your work in thread which runs the GUI of your app. So you block the whole app!
There are some ways to avoid this problem:
1. Use threads
Count in a thread and send the changes as a (User-)message to the main window.
2. Use a timer
Create a timer when clicked on "Start" and kill it when clicked on "Stop"
In the timer routine you can do your UpdateData().
A propos: Never forget to call UpdateData(TRUE) before UpdateData(FALSE) !!
Learning to make a good desing will save you a lot of trouble!
Bye, Karl
|
|
|
|
|
I'm using VC6 SP5. Sometimes whilst coding I right click on the source code window, to bring up the context menu, and then click the ClassWizard item. Sometimes for seemingly no reason at all, the ClassWizard item is disabled, and will stay displayed until I close down, and restart VC6.
Anyone know why?
|
|
|
|
|
Hi,
I get an Stack Overflow in my project.
( Had problems with w98 and so start work under NT4, after some time my w98 was reinstalled, so I want to run the app under w98 ...)
Does anyone know where I can enlarge the Stacksize.
Thanks
RW
|
|
|
|
|
use (/STACK:reserve[,commit]) linker option.
Normally 1MB of stack is more than enough
|
|
|
|
|
It looks like infinite recursion problem. Increasing the stack size won't help you in this case.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Are there any more relevant websites?
|
|
|
|
|
You can use Vision SDK from Microsoft.
http://www.research.microsoft.com/projects/VisSDK/
|
|
|
|
|
Hi there,
In our aboutbox we want to write the version informationa about the .exe were developing.
I was wondering if anyone know of any mfc way to retrieve the information ?
K
|
|
|
|
|
AFAIK, MFC doesn't help there. You need to code using the following API functions:
GetFileVersionInfoSize
GetFileVersionInfo
VerQueryValue
First, you call GetFileVersionInfoSize to get the size of the version block. Next, allocate the memory and call GetFileVersionInfo. Finally, retrieve version # using VerQueryValue.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
OK, I know this sounds crazy (or at least it does to me), but I apparently when using the ListView control with multi selection turned on, you do not get WM_LBUTTONUP messages. (Q149275 and Q149326 in MSDN). Does anyone know of a better workaround than hassling with setting a window Hook to try and trap the message ? It definitely is there in - you can see it using Spy++.
What a stupid damn thing to have to track down ! Oh well -
Any help will be much appreciated
|
|
|
|
|
Does WM_LBUTTONUP show up in PreTranslateMessage? Just an idea
|
|
|
|
|
These KB articles describe problems with Visual Basic control, not the listview in general. And you see these messages in Spy++ - so what's the problem - your handler is not called?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Well first off I'm not using MFC though I did a test and the same thign happens.
I have sub classed the listview control, and in my WndProc the WM_LBUTTONUP does not get called except under odd circumstances as described in the KB articles. For example - I can click on another window, drag the mouse ovwer the list view, and then release, and then I get a WM_LBUTTONUP, but just a press and release of the mouse on the listview control does not send a WM_LBUTTONUP.
If I set the LVS_SINGLESEL style bit then I do get WM_LBUTTONUP as long as I dont click on any item. This is very weird ? This also happens in MFC. I don't know if this matters but I am using VC++ 6.0 professional with no service packs - maybe this is the problem
|
|
|
|
|
I'm afraid service packs are not a issue here. The problem exists deep inside comctl32.dll, where list control wndproc lives.
From the "Default List View Message Processing" in MSDN:
"WM_LBUTTONDOWN: Processed in different ways depending on whether a click or drag operation is being initiated. To determine which operation is involved, the list view control enters a modal message loop until either the button is released or the mouse is moved. [...] If dragging begins over the window background, the list view control enters another modal message loop, enabling the user to form a rectangle by dragging the mouse. Items within the rectangle are selected."
The keywords are "modal message loop" - listctrl wndproc uses its own GetMessage/TranslateMessage/DispatchMessage loop, which you can't override - seems that you'll need a hook.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hello everybody. I'm trying to create a fairly simple test application using MFC _without_ the AppWizard (I hate wizards). I'm trying to implement a static vertically split window with a different view in each pane. I have had no luck so far; I keep getting an assertion error within winocc.cpp when I try to run it (I've tried debugging, but don't understand a lot of the code in winocc.cpp).
Now my question is this: Could someone show me a simple app implementing a vertical splitter window with two different views (without using the AppWizard)? I don't need anything fancy, just a bare bones SDI app.
|
|
|
|
|
Why don't you create one with the wizard and then look through it. The *point* of the wizard is to save you the set up time that you seem to want to spend yourself, so it seems natural that you let it show you how it is done, then you can do it yourself.
To counter any hint of rudeness in the above, I admit to not using the ClassWizard terribly often because I like putting everything in myself.....
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Hi-
-Pls post the code- if you want specific help -
Ok, you dont like the AppWizard, but I am sure you have the following..
1. A CFrameWnd derived class
2. A CView derived class ( for the left pane)
3. A CView derived class ( for the right pane)
I assume you also dont like ClassWizard, in that case
1. Manually override the OnCreateClient function in the CFrameWnd derived class.
2. Add a member variable CSplitterWnd (m_wndSplitter) in the CFrameWnd dervied class.
3. Add the following code to the OnCreateClient function..
.....
m_wndSplitter.CreateStatic(this, 2,1);
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(LeftView),CSize(rect.Width(),rect.Height()), pContext);
m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(RightView),CSize(rect.Width(),rect.Height()/4), pContext);
.....
Voila thats it..
Also handle the WM_SIZE mthod if you want to..
One suggestion : If you refuse to use AppWizard or ClassWizard, you are setting yourself up for a lot of misery.
Later-
V
|
|
|
|
|
Thanks everyone. After a long and hard battle trying to do it myself without the wizard I have to admit to defeat. I cannot get it working without having debug assertions flying left and right. So I have seen the err in my ways and have switched to the dark side. After only about twenty minutes of getting familiar with the wizards I finally have my splitter window working.
|
|
|
|
|
What is my wrong in this code for dialing ???
VARIANT var;
CString szTemp("+++ATDP118\n");
var.vt = VT_BSTR;
var.bstrVal = szTemp.AllocSysString();
m_comm.SetPortOpen(TRUE);
m_comm.SetOutput(var); // WON'T WORK !!!
Please help me ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Are you sure this is the spot that won't work.
Are you at least able to send a single letter.
and could you elaborate on the "// WON'T WORK !!! " part please.
cheers
Alfadhly
It is Illogical to define an inventor by his invention
|
|
|
|
|
I'm using the following code which works (I've tested it until I dropped on the floor, so believe me):
m_pMSComm->SetRThreshold(1);
m_pMSComm->SetSThreshold(1);
m_pMSComm->SetInBufferCount(0);
m_pMSComm->SetOutBufferCount(0);
m_pMSComm->SetCommPort(m_iCommPort);
// Standard setings: 9600 baud, no parity, 8 data, and 1 stop bit. "9600,N,8,1"
m_pMSComm->SetSettings(m_sCommSettings);
// We want to read the buffer in it's whole
m_pMSComm->SetInputLen(0);
// Open the gates!
m_pMSComm->SetPortOpen(true);
// Call number 37 (for ISDN modems, use ATB20DT37)
CString sMessage = "ATDT37";
COleVariant vSend = sMessage;
m_pMSComm->SetOutput( vSend );
Hope this helps a little. Let me know where the problem lies.
Structured programming vs. chaotic mind boggling
|
|
|
|
|
I wrote it, but this code won't work, too.
My program can only open COM port, but my program can't dialing !!!
m_comm.SetRThreshold(1);
m_comm.SetSThreshold(1);
m_comm.SetInBufferCount(0);
m_comm.SetOutBufferCount(0);
m_comm.SetCommPort(3);
m_comm.SetSettings("9600,n,8,1");
m_comm.SetInputLen(0);
VARIANT var;
BSTR bstr_string = SysAllocString(L"ATDP118");
var.vt = VT_BSTR;
var.bstrVal = bstr_string;
m_comm.SetPortOpen(TRUE);
m_comm.SetOutput(var);
SysFreeString(bstr_string);
Please help me ... i need your help ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|