|
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
|
|
|
|
|
Hi I want to use th eslider control to increment/decrement a variable between a lo and hi value. The thing is I have no idea on how to dp it . I'd like some step by step help on how to use the slider control. I'm using VC6 Not .NET
|
|
|
|
|
Put a slider control on the dialog template. Use ClassWizard to create a member control variable. In the dialog's OnInitDialog() method, set the slider control's range with SetRange() . You can extract the slider value from the control by calling the GetPos() member method.
MSDN has several example projects that use a slider control: CMNCTRL1, CMNCTRL2, CTRLTEST, and FIRE.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi,
Is there a more efficient way of converting an integer value into a char array representation. Hence, the char array would be set to size four because there are 4 bytes in an integer.
|
|
|
|
|
|
No, more like binary rep only in char. I'm sending a stream of bytes.
|
|
|
|
|
Alternatively (to Ian's suggestion) if you mean to treat an
integer as a four byte character array you can do so by casting:
int i = getValue();
char* p = reinterpret_cast<char*>(i);
However, that is a pretty scary thing to do, since obviously the
string will not be guaranteed to be null terminated (unless
i&0xFF is 0 on a big endian machine, or i&0xFF000000 is zero
on a little endian machine, and also assuming that sizeof(int) == 4)
Not recommended. Perhaps you could tell us what you are actually
trying to do.
|
|
|
|
|
I'm trying to convert an integer value into an array of bytes. Char array is used cause it's exactly one byte. I have library func which sends bytes over a stream if given a pointer to char array head.
|
|
|
|
|
There are couple of issues you should be concerned with here.
First of all, you need to send the integer in a representation
that all readers will accept. As you probably know, different
processor achitectures represent integers in different ways,
consequently, most likely the best representation would be a
simple ASCII stringL
void convertMe(int i)
{
char s[MAX_CHAR];
itoa(i, s, 10);
sendBytes(s);
}
where sendBytes is your sending function. If you don't care about
endian-ness, you could also send the bytes directly like this:
sendBytes(reinterpret_cast<char*>(&i), sizeof(i));
However this assumes that sendBytes is not designed to send a string,
but a block of memory (hence the second parameter which is the length
of the block to send.) If it is designed to send strings it will
fail quite often since any zero byte within the integer will terminiate
the string.
|
|
|
|
|
Something like this comes to mind:
int nNum;
char cBytes[4];
cBytes[0] = (nNum >> 24) & 0xff;
cBytes[1] = (nNum >> 16) & 0xff;
cBytes[2] = (nNum >> 8) & 0xff;
cBytes[3] = nNum & 0xff;
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Does anyone know any good FREE Chart Component is can use on ASP
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|