|
To help you with that one try something like this:
hMemDC:=CreateCompatibleDC(hdc)
hbitmap:=CreatecompatibleBitmap(hdc,w,h)
hold:=SelectObject(hMemDC,hBitmap)
...
hdc is the DC to your screen
w is width, h is height of the bitmap
And, could you try R2_NOT ??
Good luck
Rozis
|
|
|
|
|
Thank you Rozis, you are right,the code has succeed.
I have learned a lot from you, thank you!!!
|
|
|
|
|
I have an OSI model application that receives packets from datalink (via TCP sockets) examines it and send it to network layer to extract the socket information and packet type, etc. and sends to transport layer and then to application layer to send it to another application again via TCP socket for responses.
in my application when a socket goes down, I send a message from datalink to manager class that watches all 4 layers to notify the manager class for socket disconnection and manager class makes a message to send to application layer to notify it to stop receiving messages from 2nd application till the datalink socket is up again. sometimes the socket goes up and down very quickly like there is a glitch for 2-3 sec and in this case I don't want to report any socket disconnection to application layer. to summerize:
in datalink layer:
Socket 1 is down -> send socket status to manager class, Manager class should start a timer and if within 15 seconds the status of the socket remained the same, make the message for socket 1 and send it to application layer. (if the status changed to down and up within 15 seconds do not send any message to application layer)
the problem is my application is always sending and receiving messages and can't pause for a period of time.
How can I add this timer just for the socket down/up message that wouldn't trigger other application's process?
Thanks,
Chan
|
|
|
|
|
You can use a waitable timer to do this with calls like CreateWaitableTimer /SetWaitableTimer .
You can then wait on this timer using a wait function like WaitForSingleObject .
You will need to wait in a separate thread if you don't want to block your main thread.
Take a look at this sample - Using Waitable Timer Objects[^]
|
|
|
|
|
Thanks a lot, I'll see what I can do but I already have many threads and adding one more makes things very mess.
regards,
Chan
|
|
|
|
|
Sounds not like a coding problem but a design problem.
If I understood correctly... in some way you want to add a timer functionality to your application logic. There are many ways to achieve this and it depends on your current design/architecture. If your application is event based you can use timer events (e.g. WM_TIMER), if it is multi-threaded you can introduce a dedicated timer thread, if you use a 3rd party networking class it might offers some kind of timer.
In my applications I use a networking class that provides 1Hz timers and I use it for all kind of things, from timeouts to bandwidth limitations.
Hope it helps, M
|
|
|
|
|
hi friends,
i designed to get value from combobox like "com port, baudrate, party,time interval". after user selecting all parmeter and press button "connect" for example data =0x47,comport=com1, baudrate=9600,party=2 etc.. and sent to serial port then i should get 47
in the list box.
void CKeytestDlg::OpenPort( )
{
int i;
i = m_comport.GetCurSel();
m_Comm.SetCommPort(i+1);
for(i=0;i<4;i++)
if( i == m_bardrate.GetCurSel() )
{
m_bardrate.GetWindowText(baudrate);
}
if(baudrate == "2400" )
{
m_Comm.SetSettings ("2400,N,8,2");
}
if(baudrate == "4800")
{
m_Comm.SetSettings ("4800,N,8,2");
}
else
{
m_Comm.SetSettings ("9600,N,8,2");
}
m_Comm.SetInputMode (1); // Binary mode
m_Comm.SetPortOpen (TRUE); // Open it
}
void CKeytestDlg::OnButton1()
{
// TODO: Add your control notification handler code here
OpenPort();
CByteArray btArray;
BYTE bID;
bID = 0x47;
btArray.Add (bID); //Identifier byte
// btArray.Add (/*0x30);//*/bByte1); // DataByte 1
COleVariant var(btArray);
m_Comm.SetOutput(var); // Send the data.
m_Comm.SetPortOpen(FALSE);
}
plz kindly help me
|
|
|
|
|
shanmugarajaa wrote: plz kindly help me
With what?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am making a dialog based application , i want to disable the maximize
button , when i disable the maximize button from resources check box for maximize button , gui window hides the task bar of windows , how can i disable maximize without hiding task bar .
|
|
|
|
|
amit10i wrote: I am making a dialog based application , i want to disable the maximize button...
Disable or remove?
amit10i wrote: ...when i disable the maximize button from resources check box for maximize button , gui window hides the task bar of windows...
Are you referring to the dialog's title bar?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
yes i am referring to dialog's title bar,
either disable or remove , anything will suffice , preferably removing the maximize button ,
|
|
|
|
|
amit10i wrote: preferably removing the maximize button ,
How about removing the WS_MAXIMIZEBOX style?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am working on Excel automation using VC++(unmanaged).
Following are the two issues:
1. Whenever Excel is closed , Excel.EXE is not getting closed.
My application should track opening and closing of Excel.
I released application pointer(Excel::_ApplicationPtr) but same problem.
I googled and got few solutions, but nothing worked.
I tried :
Excel::_ApplicationPtr XL.
XL->Quit();
XL->Release();
XL = NULL;
but none of these worked.
2. Is there any callback which tracks excel.exe is closed?
Please give me clue to solve these issues.
Regards,
KTTransfer.
|
|
|
|
|
Just try this - Set the 'Visible' property to TRUE and then call Quit method.
-- Its a guess, if not worked, you may have to find the EXCEL process and terminate the process using TerminateProcess function.
|
|
|
|
|
Are you calling GC.Collect()?
|
|
|
|
|
It must have something to do with the way you are accessing Excel's type library. I've got several Excel automation projects that close Excel just fine. The only difference is that they don't use the #import directive. The one that does use #import simply calls app->Quit() .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Again see below... I have had this error before. I have code to controls add-in installation to avoid warnings from one xla referencing another.
// The following line is necessary to be sure that app object is released when we finish, because
// the Garbage Collector is non-deterministic and by default can leave app unreleased.
System::GC::Collect();
System::GC::WaitForPendingFinalizers(); //GetActiveObject Error is this line is excluded
|
|
|
|
|
This is managed code. I think the OP is using unmanaged code.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Then are you using the following?
//Release the no-longer-needed IUnknown...
if (pUnk)
pUnk->Release();
//... Add your automation code for Excel here ...
//Release pDisp when no longer needed...
if (pDisp)
pDisp->Release();
//Cleanup COM...
CoUninitialize();
|
|
|
|
|
Ted2102 wrote: Then are you using the following?
No, I use smart pointers whenever possible.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Then instead of #import what else we can use to include?
I tried making it visible and then used quit but no use.
It's not getting killed.
|
|
|
|
|
Hi to Everyone.
Its been a long time, I have been searching for an clear cut idea of
....shallow copy and deep copy with regards to Copy constructor and assignment operator.
I search the web, but many places has been confused me...I know that the problem comes only when we do use of pointers...But, dont know exact situation and solution for it. when to use which one..ie in which situation to used which one....
Can anyone please help me understanding the concept better.
A good example problem with relating to all these topic would be appreciated.
May be could you please relate the example with the following situations
1. Default copy constructor
2. Default assignment operator
3. overloaded copy constructor
4. overloaded assignment operator
Thanks in advance
-----------------------------
I am a beginner
|
|
|
|
|
There's no difference concerning this behavior between a copy constructor and an assignement operator, so my explanation is valid for both.
The problem with a default constructor is that it simply copies byte by byte all the content of your class. This is ok for most of the cases when your class contains only plain data type for instance.
Now, if you have a class which contains a pointer and then if you copy your class using a shalow copy, both class instances will contain a pointer pointing at the same memory location. If you have a destructor like this:
MyClass::~MyClass()
{
if (myPointer)
{
delete myPointer;
myPointer = NULL;
}
}
Then you will end up in big troubles once one of the class instances gets destroyed because its destructor will be called and you will end up with a pointer pointing to memory which has been release in your other instance.
So, what you have to do instead is allocate a new pointer and copy the content when you copy the class:
MyClass::MyClass(const MyClass& copy)
{
myPointer = new ....;
......
}
|
|
|
|
|
Thanks a lot for your valuable reply
Got some more doubts again.
Cedric Moonen wrote: The problem with a default constructor is that it simply copies byte by byte all the content of your class.
What does the code of default constrictor is...what I mean is what is the code present in the default constructor?
Cedric Moonen wrote: Now, if you have a class which contains a pointer and then if you copy your class using a shalow copy
Could you please elaborate this, what exactly is meant by copying using shallow copy? Does this mean copying with the default copy constructor what we have?
-----------------------------
I am a beginner
|
|
|
|
|