|
Is it possible to make calling process's windows invalidate when WaitForSingleObject was called? The scenario is that when the calling process start an installation package thread the package will take the portion of the process' windows, this portion will only be repainted when the install thread exit. But I still want the process' window irresponsive while the package is installing.
|
|
|
|
|
What are you doing exactly ? You start an 'instalation'package in a separate thread and in the main thread, you directly use WaitForSingleObject ? That is a bit useless. Because of course calling WaitForSingleObject will block the current thread until your instalation is finished, thus the GUI will freeze.
I think a better solution would be to have a timer that will check regularly if the process is still running, with GetExitCodeProcess[^]. If the function returns STILL_ACTIVE (259), the process is still running.
|
|
|
|
|
Cedric Moonen wrote: What are you doing exactly ? You start an 'instalation'package in a separate thread and in the main thread, you directly use WaitForSingleObject ? That is a bit useless
What I'm trying to do is to prevent the user from doing anything with main thread's windows while the package is installing, but this way the portion taken by the package window overlapped with main thread widow, when main thread windows removed that area appears blank. I don't want that blank.
|
|
|
|
|
LiYS wrote: but this way the portion taken by the package window overlapped with main thread widow, when main thread windows removed that area appears blank. I don't want that blank.
That is not because the window of the installation package overlap that your main thread window is blank. It is because you block the main thread with the call to WaitForSingleObject (as I explained in my previous post). If your main thread is blocked, that means your window cannot process any messages anymore (which include paint messages also). So, your window stay blank.
The way to do it is to start your installation in another thread so that you can safely call WaitForSingleObject and then inform you main thread (by posting a message) when the process is finished.
LiYS wrote: What I'm trying to do is to prevent the user from doing anything with main thread's windows while the package is installing
You need to manage that yourself: for example disable the controls on your window or things like that. I don't think there is an easy way to do that (but I might be wrong).
|
|
|
|
|
Cedric Moonen wrote: That is not because the window of the installation package overlap that your main thread window is blank. It is because you block the main thread with the call to WaitForSingleObject (as I explained in my previous post). If your main thread is blocked, that means your window cannot process any messages anymore (which include paint messages also). So, your window stay blank.
I think that way too.
Cedric Moonen wrote: The way to do it is to start your installation in another thread so that you can safely call WaitForSingleObject and then inform you main thread (by posting a message) when the process is finished.
That's the way I adopted now. But the question is before the main thread informed about the sub thread completion how can the main thread process WM_PAINT message, I provide WaitForSing.. with INFINITE.
Cedric Moonen wrote: You need to manage that yourself: for example disable the controls on your window or things like that. I don't think there is an easy way to do that (but I might be wrong).
It is a method, but not suitable in my scenario.
|
|
|
|
|
LiYS wrote: That's the way I adopted now. But the question is before the main thread informed about the sub thread completion how can the main thread process WM_PAINT message, I provide WaitForSing.. with INFINITE.
What I meant is that where you start your installation package (I suppose it is an external app and you start a new process right ?) you put there the WaitForSingleObject. Thus you will have the WaitForSingleObject that blocks a separate thread and not the main thread.
|
|
|
|
|
Dear all
how to resolve this function does not take 1 parameters"? it is "ZhiFangTu(midu2)",". urgent!!!!!!!!!!
Li Zhiyuan
19/10/2006
|
|
|
|
|
li zhiyuan wrote: how to resolve this function does not take 1 parameters"? it is "ZhiFangTu(midu2)",". urgent!!!!!!!!!!
pardon!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I think the error message was clear enough, no ?
This simply means that you passed 1 parameter to your function (ZhiFangTu) and it doesn't take 1 parameters (check your function to see how many parameters you need to pass).
li zhiyuan wrote: urgent!!!!!!!!!!
This is a forum. People won't answer you faster just because you scream 'urgent'. Be polite and patient.
|
|
|
|
|
li zhiyuan wrote: urgent!!!!!!!!!!
Don't let your emergency become someone else's problem. Or, to borrow a related quote, "A lack of planning on your part does not constitute an emergency on mine."
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I want to write a game program can support two joystick(USB head)
Now I success to control player one's joystick.
But how to I control player two's joystick.
What I should set DirectInput to support two joystick?
Do any webs have any sample or book mentioned it?
My Source Code as below:
case JOYSTICK:
if(FAILED(m_Input->GetDirectInputCOM()->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumJoysticks, this, DIEDFL_ATTACHEDONLY)))
return FALSE;
if(m_pDIDevice == NULL)
return FALSE;
DataFormat = (DIDATAFORMAT*)&c_dfDIJoystick;
break;
// Set the windowed usage
m_Windowed = Windowed;
// Set the data format of keyboard
if(FAILED(m_pDIDevice->SetDataFormat(DataFormat)))
return FALSE;
// Set the cooperative level - Foreground & Nonexclusive
if(FAILED(m_pDIDevice->SetCooperativeLevel(m_Input->GethWnd(), DISCL_FOREGROUND | DISCL_NONEXCLUSIVE)))
return FALSE;
// Set the special properties if it's a joystick
if(Type == JOYSTICK) {
// Set the special properties of the joystick - range
DIprg.diph.dwSize = sizeof(DIPROPRANGE);
DIprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
DIprg.diph.dwHow = DIPH_BYOFFSET;
//DIprg.diph.dwHow = DIPH_BYID;
DIprg.lMin = -1024;
DIprg.lMax = +1024;
// Set X range
DIprg.diph.dwObj = DIJOFS_X;
if(FAILED(m_pDIDevice->SetProperty(DIPROP_RANGE, &DIprg.diph)))
return FALSE;
// Set Y rangine
DIprg.diph.dwObj = DIJOFS_Y;
if(FAILED(m_pDIDevice->SetProperty(DIPROP_RANGE, &DIprg.diph)))
return FALSE;
// Set the special properties of the joystick - deadzone 12%
DIpdw.diph.dwSize = sizeof(DIPROPDWORD);
DIpdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
DIpdw.diph.dwHow = DIPH_BYOFFSET;
DIpdw.dwData = 128;
// Set X deadzone
DIpdw.diph.dwObj = DIJOFS_X;
if(FAILED(m_pDIDevice->SetProperty(DIPROP_DEADZONE, &DIpdw.diph)))
return FALSE;
// Set Y deadzone
DIpdw.diph.dwObj = DIJOFS_Y;
if(FAILED(m_pDIDevice->SetProperty(DIPROP_DEADZONE, &DIpdw.diph)))
return FALSE;
|
|
|
|
|
For OLEDB coonection with databse i am folowiwng steps....can anybody answer me one thig...is this the only way to do OLEDB coonection....or is there some other way.....
1. insert
2. new atl object
3. dataaccess
4. consumer.
1) Open the Add Class wizard and select "Add ATL Support to MFC". Press 'Open' and to close the wizard and then choose Ok
on any subsequent dialogs.
2) Open the Add Class wizard again and select 'ATL OLEDB Consumer' and hit 'Open'.
3) The ATL OLEDB Consumer Wizard will open. Uncheck the 'Attributed' checkbox and select 'DataSource' to open
the Datalink Properties dialog.
4) In the Provider tab, choose 'Microsoft Jet 4.0 OLE DB Provider'. Press Next.
5) Under the Connection tab, enter the access database name (such as Northwind.mdb). Set the appropriate logon
info (or use the defaults). Press the Test connection button to verify if the connection has succeeded.
6) Hit the Okay button to close the DataLink Properties dialog.
Next you must choose the View, table or stored procedure to connect to.
7) In the Select Database Object dialog, expand the 'Tables' node and choose 'Employees'. Press okay.
8) Press 'Finish' to close the ATL OLE DB Consumer Wizard.
9) As before in the ODBC generated code, remove the #error line.
|
|
|
|
|
|
Hi guys,
I have a doubt.
Check the code below you'll see.
[code]
//test.h
#ifndef TEST_H
#define TEST_H
class Base
{
public:
virtual void annunce(void);
virtual ~Base();
};
class Derived : public Base
{
private:
//Base::annunce;
virtual void annunce(void);
virtual ~Derived();
};
#endif
//test.cpp
#include <iostream>
#include "test.h"
using namespace std;
void Base::annunce(void)
{
cout<<"Base"<<endl;
}
="" void="" derived::annunce(void)
="" {
="" cout<<"derived"<<endl;
="" }
="" int="" main(void)
="" {
="" base="" *base="new" derived();
="" this="" line="" can="" be="" compiled="" ok="" and="" run="" too.why?
="" base-="">annunce(); //*
delete base;
return 0;
}
[/code]
See, the line with '*' disables the "private". How can this happen?
My compiler is VC60.
Is this the compiler's fault?
If not, maybe it is because access level is used in compilation which is "static" and the virtual function invokation is dynamically resolved during execution. When compiler checks, it only thinks "Base's annunce,ok, it's public". But actually the Derived's annunce is invoked which is private.
Compiler has no idea about this.
So am i right?
I need an explanation.
Thanks a lot.
Never understand radical version
|
|
|
|
|
From the compiler's point of view it's public relative to a Base pointer.
I guess you know that because you tried it
Does it make sense to hide a virtual function in derived classes?
I can't think of a good reason but apparently since one can still get at it anyway through
the base class I guess it doesn't matter...
Mark
|
|
|
|
|
I have noticed in application I'm working on that if the screensaver comes up at any time, it seems to destroy the direct3D rendering. By destroy, I mean all the windows containing a rendered image are filled with multicoloured gibberish. The only way to restore the rendering seems to be to shut the application down and restart it. I'm guessing it may be something to do with the render device losing it's handle or something. Has anybody encountered anything like this before?
When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!!
|
|
|
|
|
Hi everybody:
I am a beginner programmer.I have one question:
I want to add a button on my dialog,when I click the button,I can print my controls by the printer. the control is on my dialog.such as ClistCtrl and so on ,I really have on idea,who can give me some good advices? Thanks very much!
beginner
|
|
|
|
|
What do you need?print or add a button on dialog?
|
|
|
|
|
Hello Everyone,
I'm a newbie, Please help me!
I'm adopting the code that could redirect a console output into the MFC Edit box.
My problem is, i want to have a live redirection from the console output to the edit box because i have a console application that will run about 5-10 mins and produces lots of information (output) in between those time in the command line.
My recent code will just wait the application to finish up before it could redirect the output from the command line to the Edit box.
Please help!.... thank you very much..
-rupert-
i need to learn more... i want to be like you guys... i'm just a begginer
|
|
|
|
|
|
I have this simple code in c++ and I was wondaring if anyone can tell me what does it do.And I mean line by line. Tnx I know what it does i just can figure out what it does in the lines. tnx again
#include
using namespace std;
main(){
int a,b,i,j;
cout<<"Vpisi a ";
cin>>a;
cout<<"Vpisi b ";
cin>>b;
for(i=1;i<=a;i++)
{
for(j=1;j<=b;j++)
{
if((i==1)||(i==a))
{
cout<<"*";}
else{
if((j==1)||(j==b))
{
cout<<"*";}
else{
cout<<" ";}
}
}
cout<<endl;
}
system("pause");
return 0;
}
=""
=""
<div="" class="ForumSig">I'm The Stig
|
|
|
|
|
First of all, use the pre and code tags when posting code so that it is formatted properly:
#include <iostream>
using namespace std;
main()
{
int a,b,i,j;
cout<<"Vpisi a ";
cin>>a;
cout<<"Vpisi b ";
cin>>b;
for(i=1;i<=a;i++)
{
for(j=1;j<=b;j++)
{
if((i==1)||(i==a))
{
cout<<"*";
}
else
{
if((j==1)||(j==b))
{
cout<<"*";
}
else
{
cout<<" ";
}
}
}
cout<<endl;
}
system("PAUSE");
return 0;
}
Basically, it is printing a rectangular box of *'s filled with empty spaces.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Ray_mond wrote: using namespace std;
This tells me this is C++ and not C
Ray_mond wrote: int a,b,i,j;
This tells me the person who wrote it was a C programmer, or learned from one. Don't create variables until you need them, and ALWAYS give them an initial value.
And one per line doesn't hurt, either.
Ray_mond wrote: cout<<"Vpisi a ";
Outputs text. Goodness knows why - what's Vpisi ?
Ray_mond wrote: cin>>a;
Accepts an integer value into a.
Ray_mond wrote: for(i=1;i<=a;i++)
{
for(j=1;j<=b;j++)
{
if((i==1)||(i==a))
{
cout<<"*";}
else{
if((j==1)||(j==b))
{
cout<<"*";}
else{
cout<<" ";}
}
}
cout<<endl;
}< blockquote="">
Loops a and b times to draw a box.
Generally, one would loop from 0 to a, not 1 to a-1.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Two questions
1. Why does the following code gives syntax error in VC++ (6.0) ??
It should initilize the struct elements.
The struct is declared / used in class.
( Does that makes a difference as opposed to "plain" C ?)
struct Structure_Tag
{
int test1;
int test2;
}m_Test = {0,0};
2. In the following code the pTest is not initialized and I am getting "Access violation". How do I do that if I cannot initialize as shown above?
...
pTest->test1 = 0;
...
struct Structure_Tag
{
int test1;
int test2;
}*pTest;
Thanks for your help.
|
|
|
|
|
Vaclav_Sal wrote: struct Structure_Tag
{
int test1;
int test2;
}m_Test = {0,0};
Use:
struct Structure_Tag
{
Structure_Tag()
{
test1 = 0;
test2 = 0;
}
int test1;
int test2;
} m_Test;
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|