|
pDC->GetSafeHdc(); It will return a pointer to the existing memory or allocate the memory and then return the pointer to this allocated memory.
OR
how i can release this memory
|
|
|
|
|
GetSafeHdc() does not return a pointer. It returns the handle of the device context - you don't need to "release" it.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
It returns a handle to an exiting HDC or NULL. If you single step through the code you will see that calling GetSafeHdc() is equivalent to return(hdc?hdc:NULL), which is kind of silly if you ask me. Because if the test codition faile "hdc?" then the hdc is already equivalent to NULL. The long and the short of it is that GetSafeHdc() does not allocate any memory, it just makes sure that the HDC returned is either valid or NULL.
INTP
Every thing is relative...
|
|
|
|
|
anilksingh wrote: pDC->GetSafeHdc();
just return the reference to selected DC.. the CDC it self manage life cycle of the HDC object.. so you don't need to worry about it.
Secondly you can use DeleteDC api to delete DC
"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
|
|
|
|
|
Hi All.
I want to write some code that have some method that in create bitmap of the current screen.
What i mean is when this method is call - there will be create file in name X.bmp that contain the info of the screen ( line pressing on PrtScn button ).
How can i catch the picture ? what windows method (maybe API function) i need to use ?
|
|
|
|
|
You may want to look up PrintWindow and WM_PRINT . There are many other techniques, which you choose depends on what OSs you need to support.
Steve
|
|
|
|
|
I will not explane how it is done, but I suggest searching using the keywords "screen capture". There are lots of Web articles on the subject, and there is probably still a code sample in the MSDN somewhere (the origanal example is probably 15 years old now). I believe there are a few articles at CP on the subject.
INTP
Every thing is relative...
|
|
|
|
|
|
#import "msxml3.dll" rename_namespace ("NEW_MSXML2")<br />
using namespace NEW_MSXML2; <br />
#import "MSSOAP30.dll" exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", "_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME") rename_namespace ("NEW_MSSOAPLib30")<br />
using namespace NEW_MSSOAPLib30;
In Debug mode, it creates MSSOAP30.tli and MSSOAP30.tlh files which has NEW_MSXML2 parameter,but in Release mode those two files are getting created with MSXML2 parameter.
Any Idea whats happening?
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
super wrote: In Debug mode, it creates MSSOAP30.tli and MSSOAP30.tlh files which has NEW_MSXML2 parameter,but in Release mode those two files are getting created with MSXML2 parameter.
Better post this problem in Microsoft newsgroup!
"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
|
|
|
|
|
What if it is some sort of preprocessor issue. I think using the "NEW_" in your new name space name could be causing a problem.
If you called it the "123123_" namespace instead, does that work?
I have seen DUMBER issues than this with preprocessors before. I am leary of calling ANYTHING "NEW" these days, since that seems to be the magic keyword ever since C++ came out
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Hi,
Can I write a shell extension which can process my own shell format?
For example: I have an application which has own data format, and when
drag from this applicaion and drop on explorer, the extension can process this data format.
It's like when you drag some texts and drop on explorer, which generate some special file.
Of course, I want generate my own files.
Anyone can help me?
|
|
|
|
|
How do I dynamically create a button (for example).
I understand how to create a button in code
ie CButton pBut* = new CButton()
pBut->Create( ..... )
but how do I trap when the button is pressed? I can't add entries to the message map because at design time the button doesnt exist?
TIA
|
|
|
|
|
you should overide the OnCommand function. The HIWORD of the wParam contains the action and the LOWAORD of wParama contains the Id of control
nav
|
|
|
|
|
For handling the evenmts on the buttons:
You have to override onCommand method and then in this you can check the id and perform the operations:
In onCommand:
you can get the id in LOWORD(wParam).
Check this and write the code in the following loop.
Cheers
Ganesh
|
|
|
|
|
The last argumen of button.Create is button id. You can use it in message map
CButton *pButton = new CButton;
pButton.Create(WS_VISIBLE|WS_CHILD,CRect(10,10,110,30),this,1 /*Id of the button any id which is unique*/ );
void OnHandler(void)
{
// Something
}
ON_BN_CLICKED(1 /* Last argument of create */,OnHandler)
MANISH RASTOGI
|
|
|
|
|
manish rastogi wrote: ON_BN_CLICKED(1 /* Last argument of create */,OnHandler)
He cannot use a message map as buttons are created dynamically.
Owner drawn
Jesus Loves
|
|
|
|
|
He can if he knows what the ID's will be at compile time...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
True. But it's not flexible.
Owner drawn
Jesus Loves
|
|
|
|
|
Is there a way to dynamically create an ID?
|
|
|
|
|
ID acts as a unique identifier for the control that you are creating. So make sure that they are unique.
Owner drawn
Jesus Loves
|
|
|
|
|
I realize that, so is there any way to ask the framework to return a unique ID
|
|
|
|
|
Look in the header 'Resource.h'. Near the bottom of the file you should see an entry that looks something like:
#define _APS_NEXT_CONTROL_VALUE 1021
(The actual number in the definition depends on your particular project.)
You can use this MACRO as the value for your first dynamically created control. Just keep incrementing the value to get a new unique value for each dynamic control.
Dan
Remember kids, we're trained professionals. Don't try this at home!
|
|
|
|
|
Look up CreateWindow() in the MSDN, a button is just another window. Setting the dwStyle parameter to BUTTON should produce a button. You will need to do a little studying to figure out how to handle the result of pressing the new button, it easier to figure out in C than when using MFC.
INTP
Every thing is relative...
|
|
|
|
|
look a this Link[^]
codito ergo sum
|
|
|
|