|
How can you draw a bitmap outside of OnPaint() function?
calling "CPaintDC dc(this)" outside of OnPaint() compiles and executes, but doesnt work.
Kevin Shaffer
kshaff03@msn.com
|
|
|
|
|
CDC* dc = GetDC();
dc->BitBlt(...);
ReleaseDC(dc);
--
Sancte Míchael Archángele, defénde nos in proélio contra nequítiam et
insídias diáboli esto præsídium. Imperet illi Deus, súpplices deprecámur:
tuque, princeps milítiæ cæléstis, Sátanam aliósque spíritus malígnos, qui
ad perditiónem animárum pervagántur in mundo, divína virtúte,
In inférnum detrude. Amen.
|
|
|
|
|
Jorgen's method is one way. Another is to use CClientDC(this)
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"
|
|
|
|
|
Hi,
I'm trying to develop an process host like "svchost.exe". But i'm in trouble with method calling from a different process. As a result i want to call a function from another process and get its return value. Can i do that? What way should i follow to do that? By the way i can get process number which i created.
Second question is, how can i create "wait status" process? These processes should be in wait status until i call a function from this process?
Thank you...
Orkun GEDiK
ASTRON
|
|
|
|
|
|
Ok. But i can't use WaitForSingleObject() because processes should be in "wait status". I don't want to wait end of process. If i use WaitForSingleObject(), i should wait end of process. But process shouldn't be stop. Process should be wait for a signal from another process without termination.
Regards...
Orkun GEDiK
ASTRON
|
|
|
|
|
For C++ code I am writing for a COM server I need a functionality where I have a fileName as Input and need to know if the File exists !
Preferably non MFC code is desired !
would a call like
string fileName
.
.
FILE *fPtr;
fPtr=fopen(fileName.c_str(), "r");
can i test fPtr and judge if the file is present or not ! Is it safe to do that ?
|
|
|
|
|
A pure Win32 API solution:
<code>
bool DoesFileExist(LPCTSTR pFileName)
{
WIN32_FIND_DATA findData;
HANDLE hFind = FindFirstFile(pFileName, &findData);
if (hFind == INVALID_HANDLE_VALUE)
return false;
FindClose(hFind);
return true;
}</code>
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Here are at least two ways:
_access();
_stat();
GetFileAttributes();
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi All!
Trying to get the image of a window using Hbitmap,DC,Memory DC and BitBlt.
This works fine, but since the function BitBlt copies from the screen, I am having tough time gettin the image of a hidden or partially shadowed window.
So is it possible to get the image of a window(even if its partially hidden) if we know its DC? I would also like to get more information on how does windows actually renders a DC. Can we force the rendering to a memory DC or memory buffer (instead to the screen) from where the image can be copied?
Thanks!
-Vladimir India
|
|
|
|
|
u can send it a wm_paint message and pass a dc in
it should render to the dc u pass in
"there is no spoon" biz stuff about me
|
|
|
|
|
Sorry dear,
i'm afraid but wm_paint doesnt solves the problem!
-vladiir_india
|
|
|
|
|
|
Hats off!
undoubtedly, its a great article.
But something strange happened when i used WM_PRINT. None of the windows got printed, except my very own application window.
Actually my application is kind of SPY++, so it identifies a window by mouse cursor position. The HWND is then send to the folowing function get_image().
following is the code snippet i'm using currently:
BOOL CVenomDlg::get_image(HWND hwnd)
{
HBITMAP hBitmap ;
HDC hdc,hdcMem;
BITMAP bitmap ;
RECT rc;
::GetWindowRect(hwnd,&rc);//get the bounding rectamgle
hdc=::GetDC(hwnd);//get the dc
hdcMem = ::CreateCompatibleDC (hdc) ;//create memory dc
hBitmap = ::CreateCompatibleBitmap (hdc, rc.right-rc.left, rc.bottom-rc.top) ;//create bitmap
::GetObject (hBitmap, sizeof (BITMAP), &bitmap) ;//get bitmap info into bitmap struct
::SelectObject (hdcMem, hBitmap) ;//make the bitmap as the surface of memory dc
::SendMessage(hwnd, WM_PRINT , (WPARAM) hdcMem,PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);
::ReleaseDC(hwnd,hdc);
//copy the data to clipboard also!
::OpenClipboard(hwnd);
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, hBitmap);
::CloseClipboard();
//the clipboard contains a black rectangle???
//copy the image to static control...
//my own stuff to copy the hdcMem contents to a
//static control
.
.
.
.
::DeleteObject(hdcMem);
::DeleteObject(hBitmap);
return(TRUE);
}
-Vladimir India
|
|
|
|
|
Hi,
From my SDI application I can open XML documents in my application using the Menus File | Open.
I want to open the XML documents in my application by right-clicking on the XML document and then selecting Open With and selecting my application.
Can anyone please tell me how I can do that?
It’s urgent
Thanks in advance
|
|
|
|
|
Basically, you need to create a menu in the resource entry. Create a new menubar, but don't add the menubar to your frame window.
Now make a submenu and add your menu items. Make sure the "Open With" entry has the same ID as "Menu File | Open". This will reuse your already existing code to open an XML document since it will call the event handler you already have in your message map.
In your application you need to trap the right click event, i.e. WM_RBUTTONDOWN. Then fire up the submenu using this (pseudo)code:
HMENU hMenuBar = ::LoadMenu(hInstance, ID_OF_YOUR_NEWLY_CREATED_MENUBAR);
HMENU hSubMenu = ::GetSubMenu(hMenuBar, 0);
TrackPopupMenuEx(hSubMenu, TPM_SEE_MSDN_DOCS, x_coord, y_coord, 0, m_hWndOfEventReceiveingWindow, NULL);
Since you didn't specify what toolkit you are using, I used the Win32 API. If you are using MFC or ATL/WTL, you can easily find the corresponding functions since they more or less map 1:1
--
Sancte Míchael Archángele, defénde nos in proélio contra nequítiam et
insídias diáboli esto præsídium. Imperet illi Deus, súpplices deprecámur:
tuque, princeps milítiæ cæléstis, Sátanam aliósque spíritus malígnos, qui
ad perditiónem animárum pervagántur in mundo, divína virtúte,
In inférnum detrude. Amen.
|
|
|
|
|
why do I need to create a menu? I guess I didn't make my problem clear enough.
any xml file in my computer-> right-click on it->Open With->Choose Program ->Other -> brows to and select my program -> OK.
so no menu creation is needed.
Now I just want to know if I do that how the XML file name is passed to my application and where do I capture that name to work on it.
|
|
|
|
|
Ah, you want to create a shell extension.
Have you looked around here?[^] Michael Dunns "The Complete Idiot's Guide to Writing Shell Extensions" should get you going.
--
Sancte Míchael Archángele, defénde nos in proélio contra nequítiam et
insídias diáboli esto præsídium. Imperet illi Deus, súpplices deprecámur:
tuque, princeps milítiæ cæléstis, Sátanam aliósque spíritus malígnos, qui
ad perditiónem animárum pervagántur in mundo, divína virtúte,
In inférnum detrude. Amen.
|
|
|
|
|
Just take a look at the registry:
HK_CLASSES_ROOT\xmlfile\shell\Open\command
That should give you some idees.
Wout Louwers
|
|
|
|
|
RECT rect;
LPCRECT rect2;
AfxGetApp()->GetMainWnd()->GetClientRect(&rect);
rect2->left=rect.left; rect2->right=rect.right;
rect2->top=rect.top; rect2->bottom=rect.bottom/6;
cdc->FillRect(rect2,cb);
Why isn't this thing working? I know no other way of copying rects. Any suggestions are welcome.
---
Blääh
|
|
|
|
|
LPCRECT is a pointer, so do this:
RECT rect;
RECT rect2templ;
LPCRECT rect2 = &rect2templ;
AfxGetApp()->GetMainWnd()->GetClientRect(&rect);
rect2->left=rect.left; rect2->right=rect.right;
rect2->top=rect.top; rect2->bottom=rect.bottom/6;
cdc->FillRect(rect2,cb);
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Hmm, thanks, it helped me out...
---
Blääh
|
|
|
|
|
Ask yourself the following question; Where does rect2 point?
Also, since you're using MFC, why not use CRect ?
--
Sancte Míchael Archángele, defénde nos in proélio contra nequítiam et
insídias diáboli esto præsídium. Imperet illi Deus, súpplices deprecámur:
tuque, princeps milítiæ cæléstis, Sátanam aliósque spíritus malígnos, qui
ad perditiónem animárum pervagántur in mundo, divína virtúte,
In inférnum detrude. Amen.
|
|
|
|
|
Why not try this:
<br />
CRect rect, rect2;<br />
AfxGetApp()->GetMainWnd()GetClientRect(&rect);<br />
rect2 = rect;<br />
rect2.bottom /= 6;<br />
cdc->FillRect(rect2, cb);<br />
Or
<br />
CRect rect;<br />
AfxGetApp()->GetMainWnd()GetClientRect(&rect);<br />
rect.bottom /= 6;<br />
cdc->FillRect(rect, cb);<br />
if you don't have to use rect anyfurther...
Wout Louwers
|
|
|
|
|
My goal is detecting USB Web-Came connection in my PC for correct video capture.
I use DirectShow for my work. I did enumerating videocapture devices and always getting identical result - Web Came is in system. Independing WebCame is plug in or plug out.
How can I do it yet?
Tav
|
|
|
|