|
i got this out of an article:
Converting a metafile to a 24-bit color bitmap is simple. Just follow these steps:
Create the memory DC.
Create the device-independent bitmap.
Select the bitmap to the created memory DC.
Draw in this DC.
Select the old bitmap to DC.
I have the Metafile Created. Howevere the above instructions do not make any sense. can anayone please help me?
thanks
|
|
|
|
|
here it is with no error checking and no cleanup - both of which are very important.
HDC memDC = ::CreateCompatibleDC(hDC);
HBITMAP memBmp=::CreateCompatibleBitmap(hDC, w, h);
HBITMAP oldBMP = (HBITMAP)::SelectObject(memDC, memBmp);
::PlayEnhMetaFile(memDC, emf, &tRex);
::SelectObject(memDC, oldBMP );
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
I have handle of file for read and write from/to COM port , but I dont know which COM port .
I want understand that this handle is attached to which port (Example COM1 ).
If you can please help me .
Thanks .
|
|
|
|
|
I don't think that I understand your question. I don't know if this[^] is of any help, but the classes are very nice for serial communitation..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
You have a handle to a COM port but you don't know which COM port (e.g., 1, 2) it is, right? How did you acquire this handle?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I hook ReadFile API . Handle of file is in ReadFile hook parameters method .
|
|
|
|
|
See if this article is of any help.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I have a question. Why do you hook the read file API????? Do you want to hook COM ports? I would instead create a filter driver on top of \device\serial0, serial1, etc. You can read the object manager's Dos Device Name for "COMx" and see what device it's associated with as well, which is usually \device\serial0 in most cases, but not all.
However, it is a much cleaner method of hooking "ReadFile" and you're only called for COM ports (Unless the device is used for multiplex for multiple devices, which is a different story all together.).
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
Thanks for your notice to my question , (Excuse me , I dont know english well )
I want to hook COM Port in WinXP .
Please explain more about <object manager's="" dos="" device="" name="" for="" "comx"=""> .
Thanks alot .
|
|
|
|
|
http://www.sysinternals.com
download "Windows Object Viewer" click ong "\\??" or "\\Global" Look for "COM1". It's a symbolic link to a device such as "\Device\Serial0".
A device driver installs itself on the system as "\device\whatever". Applications want to be abstracted from being tied to any one particular device so a common set of "dos device names" are created so the application only uses the common name, which in the background, can be serviced by any device. Your driver letters are all dos device names as well.
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
Very very thanks .
Your guide help me very much .
|
|
|
|
|
I have downloaded Windows Script Engine(5.6). It is enough to
apply the ActiveX scripting to my MFC Application.I want to create the
com component and want to link with this my MFC program.
|
|
|
|
|
Hi,
I am developing an application in MFC/VC++ 6.0. I need to draw a bitmap image in a dockable toolbar and the view area should have scrolling enabled.
I thought that embedding a CScrollView derived class in the dialog box would help while declaring a custom control as the placeholder while designing the dialog box.
However, I don't know how to manually wire in the CScrollView class. I even don't know whether there is any easier way to do this.
Please help.
Thanks in advance.
|
|
|
|
|
Hi!
I'm developing an application using MFC. I've implemented Context sensitive help for the controls but is unable to do so for edit box.
In case of edit box, on right click of the mouse it displays the default help in place of my help.
Kindly help me on this,
Thanks
Pawan
|
|
|
|
|
I guess in Context Sensitive help, you cannot right click.
For a proper Context Sensitive help - click on the question mark on toolbar, the question mark gets attached to your mouse pointer and left click on the control for which you need help info.
Either a small popup window opens or a html page opens to provide information
First you should choose whether you want html context sesitive help or windows context sensitive help
Then override the respective virtual functions
|
|
|
|
|
hiho@ll
what i have:
a HBITMAP handle
no parent window
a browser helper object, which should do the job
what i need:
the upper left pixel of the HBITMAP handle
what i think how it could work: (well it doesn't work )
CWindow *tmpwin=new CWindow(::GetDesktopWindow()); // i don't have a parent
HDC hdc=tmpwin->GetDC();
SelectObject(hdc,hbmp); // select the HBITMAP
COLORREF cf=GetPixel(hdc,0,0);
return cf;
what i get:
the return RGB Values are 255,255,255
using GetLastError after the GetPixel and before Return i get ErrorCodes 6 and 8 (invalid handle, not enough space)
i'm calling the method a few times, so i get some error codes and not just one
question:
how can hdc be an invalid handle, if i use GetDesktopWindow?
how can i get "not enough space" for a bitmap which is 16x16?
a workaround i'm thinking of, but i don't know how to do:
i make my own window, use selectobject on my window, get the pixel, and destroy the window
question:
how can i make my own window? (some code would be great)
and how do i destroy the window?
btw, the only purpose of this window will be to get a valid DC to select the HBITMAP and get the pixel
thx@ll
|
|
|
|
|
Hello,
Me again! I was searching through MSDN and found the following functions usefull for your problem:
<list>GetDC() [^] for retrieving the DC of the desktop.
CreateCompatibleDC()</a>[<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceshellui5/html/wce50lrfCreateCompatibleDC.asp" target="_blank" rel="nofollow" title="New Window">^</a>] for creating a memory DC<br />
<li> <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_9v3o.asp" rel="nofollow"><code>SelectObject() [^] for placing the bitmap in the DC (Note that the bitmap can only be selected in one DC at a time!)
Using these functions, one can do the following:
HDC hMemDC = ::CreateCompatibleDC(GetDC(NULL));
HGDIOBJ hOldObj = ::SelectObject(hMemDC, hbmp);
COLORREF cf = GetPixel(hMemDC, 0, 0);
::SelectObject(hMemDC, hOldObj);
::DeleteDC(hMemDC);
return cf;
Hope this helps
P.S.
Some of your problems could be: tmpwin has no DC, which results in invalid handle errors, hbmp is already selected in a DC, hbmp is not created correctly,..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
hiho
tried your code
the same problem
tried to make my own window with CreateWindow("STATIC",NULL,WS_CHILD|WS_VISIBLE,0,0,16,16,NULL,(HMENU)NULL,g_hThisModule,NULL);
the same problem
hmm
1. how do i know if the window has a DC?
2. how do i check if hbmp is already selected? (hmm, i don't think it is, but how do i check, just to be sure?)
|
|
|
|
|
ThinkingPrometheus wrote:
1. how do i know if the window has a DC?
All windows have a DC, as long as they are visible. I don't know if they have a DC when they are invisible.
ThinkingPrometheus wrote:
2. how do i check if hbmp is already selected? (hmm, i don't think it is, but how do i check, just to be sure?)
From where do you get the handle? I think the problem lies there, since all the other windows and dc's should be valid.
You can validate this by loading your own bitmap from disk and see what that gives you.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
hiho@ll
i have to convert a string from Variant to CString (or LPCTSTR)
i read some articles about bstr conversion, but doesn't seem to work
1. i have a variant variable
2. i want to use MessageBox to show the Variant-String
how do i do this?
some code would be perfect
thx
|
|
|
|
|
I'll help with the conversion (I'm sure you can handle the MessageBox!)
CString GetString(const VARIANT* pvaData)
{
if (pvaData->vt == VT_BSTR)
return pvaData->bstrVal;
if (pvaData->vt == (VT_BSTR | VT_BYREF))
return *pvaData->pbstrVal;
if (pvaData->vt == (VT_VARIANT | VT_BYREF))
return GetString(pvaData->pvarVal);
VARIANT varDest;
VariantInit(&varDest);
if (SUCCEEDED(VariantChangeTypeEx(&varDest, (VARIANT*) pvaData, LOCALE_SYSTEM_DEFAULT, 0, VT_BSTR)))
return GetString(&varDest);
return _T("");
}
|
|
|
|
|
Check here[^]
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
wow
cool
thx to both of you
|
|
|
|
|
hi
you can take the variable of bstr type and assign variant to the bstr and then pass the bstr value in messagebox .
It works
cheers
|
|
|
|
|
If you know that the VARIANT contains a BSTR you can get the BSTR , which is really a special form of a wide-character string, and pass it to the wide-character version of MessageBox :
MessageBoxW( hWndParent, vtMyVariant.bstrVal, L"The Caption", ( MB_ICONINFORMATION | MB_OK ) )
(You could also pass in a dereferenced pbstrVal .)
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|