|
managed c++ is a marketing con, C++ is the most widely used language on the planet for commercial applications.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
thanks
|
|
|
|
|
The CxImage *i is just an image that I want to get drawn onto this CDC.
It works fine if I Draw() straight to the window DC, but if i use this class and try to BitBlt() from this to the window DC, I get nothing.
What could be causing this?
class CSomeDC :<br />
public CDC<br />
{<br />
CBitmap bmp;<br />
CBitmap *bmpOld;<br />
public:<br />
<br />
Uint32 w, h;<br />
<br />
void Init(CxImage *i)<br />
{<br />
w = i->GetWidth();<br />
h = i->GetHeight();<br />
<br />
VERIFY(CreateCompatibleDC(0));<br />
VERIFY(bmp.CreateCompatibleBitmap(this, w, h));<br />
bmpOld = (CBitmap*)SelectObject(bmp);<br />
i->Draw(m_hDC);
}<br />
};
|
|
|
|
|
Locked Ghost wrote:
VERIFY(CreateCompatibleDC(0));
For a start why is 0 being passed here. It should be 'this' me thinks.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
0 = Current display DC or something like that(Memory bad. From MSDN)
this? well, why would I want to create a DC compatible with itself, which has not been created yet? :p
|
|
|
|
|
hey Brian do u know Chris-de-Burgh ?
-=Ehsan-de-Burgh=-
|
|
|
|
|
Brian? Chris-de-Burgh? Never heard of either one
|
|
|
|
|
Locked Ghost wrote:
0 = Current display DC or something like that(Memory bad. From MSDN)
I think its for the Desktop. Is that what you want?
Locked Ghost wrote:
this? well, why would I want to create a DC compatible with itself, which has not been created yet? :p
Because that's what you do with memory dc's. Have a look around CP for CMemDC by Keith Rule.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Neville Franks wrote:
Because that's what you do with memory dc's. Have a look around CP for CMemDC by Keith Rule.
Tried, still doesn't work
And CMemDC does not do that actually.
|
|
|
|
|
I've run into this myself in the past. You are creating a DC which initially has a mono 1x1 bitmap
selected into it (look at ::CreateCompatible DC...) You need to create a HBITMAP compatible with the
end DC (e.g. Screen).
You need something like:
void Init (CxImage *i)
{
CWindowDC dcScreen (CWnd::FromHandle (::GetDesktopWindow ()));
w = i->GetWidth();
h = i->GetHeight();
VERIFY(CreateCompatibleDC(&dcScreen));
VERIFY(bmp.CreateCompatibleBitmap(&dcScreen, w, h));
bmpOld = (CBitmap*)SelectObject(bmp);
i->Draw(m_hDC);
}
I hope this helps,
Iain.
|
|
|
|
|
Yes!! It works
Huge thanks to you!
In related things, can you tellme why this destructor gives me an acccess violation?
I've seen the exact kind of thing(Selecting the old bitmap back) done in destructors before... hmm?
class CTilesetDC :<br />
public CDC<br />
{<br />
CBitmap bmp;<br />
CBitmap *bmpOld;<br />
public:<br />
<br />
Uint32 w, h;<br />
<br />
CTilesetDC(CxImage *i, CDC *target)<br />
{<br />
w = i->GetWidth();<br />
h = i->GetHeight();<br />
<br />
VERIFY(CreateCompatibleDC(target));<br />
VERIFY(bmp.CreateCompatibleBitmap(target, w, h));<br />
bmpOld = (CBitmap*)SelectObject(bmp);<br />
i->Draw(GetSafeHdc());<br />
}<br />
<br />
~CTilesetDC()<br />
{<br />
SelectObject(bmpOld);<br />
}<br />
};
|
|
|
|
|
I should have spotted this in my first reply. CDC::SelectObject (CBitmap *) returns a pointer
to a temporary CBitmap. To quote:
This function may return a pointer to a temporary object. This temporary object is only valid
during the processing of one Windows message. For more information, see CGdiObject::FromHandle
After a while, the CBitmap pointed to by bmpOld is deleted by MFC; so when you try to delete it,
an exception is raised. This is one of the reasons I use HANDLES...
You could change your class to
<br />
class CTestDC : public CDC<br />
{<br />
....<br />
CBitmap bmpOld;<br />
....<br />
<br />
CTestDC (....)<br />
{<br />
....<br />
bmpOld.Attach (SelectObject (&bmpNew)->Detach ());<br />
....<br />
}<br />
<br />
~CTestDC ()<br />
{<br />
SelectObject (&bmpOld);<br />
bmpOld.Detach ();
}<br />
}<br />
I hope this helps.
Iain.
|
|
|
|
|
I'm trying to resize of metafile. Is there a function I can use.
Thanks
|
|
|
|
|
Hi
I've got a real strange problem. I want to simulate a button-press in another app. I have a HWND wndButton , which is definately valid. Now I want to simulate the pressing of the button:
::SendMessage(::GetParent(wndButton),WM_COMMAND,MAKEWORD(::GetDlgCtrlID(wndButton),BN_CLICKED),(LPARAM)wndButton);
But this doesn't work. Does anybody know why? It works in other programs
Update: The window doesn't even react on ShowWindow(SW_HIDE) , although my HWND to the window is valid. What the hell is going on here?
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Are you sure about "(::GetParent(wndButton),"? Parent might not be what you expect. Could you check it with Spy?
|
|
|
|
|
Oh, forget my question, thanks for your effords
This code was inside a loop that never was reached
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Gregor S. wrote:
This code was inside a loop that never was reached
I don't like having to debug code but situations like this proves it's a complete necessity.
Regards,
Brian Dela
|
|
|
|
|
|
It is defiantly possible, procexp.exe(sysinternals.com) does that. Check out sysinternals.com they should have some source code for that.
|
|
|
|
|
|
Nishant S wrote:
Unfortunately they dont give out the source code for that one
Then it's probably impossible using Win32, forcing use of either (DDK documented) NT API, or (more likely, since this could be something useful) it's completely undocumented.
Perhaps you could disassemble the sysinternals code and see how its done? I've got a feeling this is in the NT API QueryObjectInformation (or something like that).
|
|
|
|
|
|
|
Nishant S wrote:
QueryObjectInformation doesnt exist
Well, I did tell you "or something like that".
Fortunately, trusty header files displays e.g ZwQueryObject and ZwQuerySecurityObject. Perhaps the source code for regmon and/or filemon could include something useful also.
But maybe this is simpler than we might think. Have you had a look at GetNamedSecurityInfo & co?
|
|
|
|
|
I just searched google groups, and there seems to be much information. Perhaps even the one your searching for
Take a look at this link
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|