|
alpha+ wrote:
so I investigated how MFC draws its own simple controls (CButton), and found that actually the parent's DC is being used for drawing the child control.
I find this statement incorrect. How did you get this?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
When you register your class for the child control, give it the class style CS_PARENTDC.
Then create an OnDraw OnPaint handler for your child control. The parent control will get the chance to paint its display first, then your child control will get its chance.
You shouldn't have to call the OnDraw handler directly, windows or MFC will take care of that for you.
|
|
|
|
|
One other thing that I forgot to mention.
In order to make a child control look transparent, you will need to handle the WM_ERASEBKGND message for you child control, and return FALSE. This will have the effect of your child control not clearing the window space below it with the default color for a window like white or whatever, and it will allow what appears on the parent control to show through for the child controls display surface.
Then when you paint the text or whatever for your child control, it will appear as though the control is transparent.
One other note, with this fix, it is no longer neccesary to use the parent windows DC. I told you in my previous post that in order to use the parent DC, set the CS_PARENTDC style for your class, this is no longer necessary.
|
|
|
|
|
You should use regions to handle transparency. They are very cool! Create an odd shaped region (CRgn ) and select it (SetWindowRgn ) into your device context. Windows will automatically paint only within the region. You can even have windows with holes!
See this article and this one too for instant inspiration.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I think that SetWindowRgn is a good way to go for irregular shaped windows and windows with holes, like you said, however, if you want the control to be transparent, but still be able to click on a that transparent portion and have your child control respond, you will need to handle the WM_ERASEBKGND message and not erase the background.
|
|
|
|
|
I'm trying to create a shortcut to a folder (rather than a file).
I've tried the IShellLink method, but it doesn't produce what I'm
after. This method requires and application to be specificed aswell.
If I specify explorer.exe, the shortcut is created with the app
c:\winnt\explorer.exe. This shortcut is on the network and is
accessed by people using NT/98 and 2k, thus it doesn't work as
explorer is in a different place!!
Does anyone know how to do a 'proper' folder shortcut?
Thanks in advance!
|
|
|
|
|
A shortcut to a folder MUST end in .lnk and a URL shortcut should end in .url
HRESULT CreateFileShortcut(
LPCSTR name,
LPCSTR workDir,
LPCSTR target,
LPCSTR args,
LPCSTR description
)
{
HRESULT hres;
IShellLink* psl;
hres = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
psl->SetDescription(description);
psl->SetPath(target);
psl->SetArguments(args);
psl->SetWorkingDirectory(workDir);
psl->SetIconLocation(target,0);
hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
if (SUCCEEDED(hres))
{
WORD wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, name, -1, wsz, MAX_PATH);
hres = ppf->Save(wsz, TRUE);
ppf->Release();
}
psl->Release();
}
return hres;
}
Todd Smith
CPUA 0x007 ... shaken not stirred
|
|
|
|
|
How can I display thumbnail for a custom image format in an explorer window?
Also, is there a simple hack to get explorer to understand other extension for a known file type when displaying a thumbnail? For example, I have these files with the extension .thm. They are really just .jpg files. How can I get explorer to see them as .jpg's?
|
|
|
|
|
Read Michael Dunn's articles on shell extensions, one of them shows how to do an icon server.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
I've read that. Unless I'm missing something, it does not deal with Thumbnails and from what I can tell, they are not just large icons.
|
|
|
|
|
Please show me a way to load and display usual image files such as jpg, gif, ... using directX technology.
Thanks a lot.
dxky
|
|
|
|
|
GDI+ is your friend - it loads and saves file types and can use directdraw surfaces.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Hi there,
Wendsday (20 March) is new year in Iran !
I wanna say "HAPPY NEW YEAR !" to all of guys here !
and God willing, we'll can solve all problems about VC++ programming in new year !!!
I wanna thanks of:
Mr.VGirish - Panov Vitaly and etc.
and my all other friends !
With Warm Regards,
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Does anyone know of an implementation of tree/list with reordering like in Internet Explorer's favourites?
Where items can be drag/dropped to their new position with a horizontal bar showing where they will appear during the drag??
--
The Obliterator
|
|
|
|
|
I use GDI+ Graphic::DrawImage to display and print a bitmap;
for display and print preview it works fine. But when printing, the bitmap is stretched or compressed on paper, depending of the printer resolution. To correct this problem, I applied a correcting factor :
long dpiPrinter = pDC->GetDeviceCaps(LOGPIXELSX);
long dpiScreen = 96; // returned by pDC->GetDeviceCaps(LOGPIXELSX)
// when displaying
double ratio = (double)dpiPrinter/dpiScreen;
destPoints[0].X /= ratio;
destPoints[0].Y /= ratio;
...
// destPoints[0...2] are the corners of the rectangle
// delimiting the zone on which the bitmap is to be printed
graphics.DrawImage(pData->pBitmap, destPoints, 3,
0, 0, bitmap.GetWidth(), bitmap.GetHeight(),
UnitPixel);
Bitmap size is now almost correct but still a bit too large.
And I don't see any reason why I have to modify the code for
printing : MFC show the correct image in print preview, so I
assumed I would get the same result on paper.
|
|
|
|
|
You have to modify the code for the reason you said - MFC showed you how it looks on the screen, but it's up to you to match that in terms of the DPI of your printer.
Have you tried using UnitInch to draw to the printer ? Just curious, I've not tried printing in GDI+ myself but it seems like it could be promising.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
After many trials it works, and here are my conclusions, or rather my observations, because I don't have a clear understanding of what's happening.
I use the MM_LOMETRIC mapmode : logical units are 0.1 mm. The coordinates of the rectangle on which the bitmap is to be drawed are initially exprimed in these logical units. When I discovered that the size and position of the bitmap on paper were depending of the resolution of the printer, I thought of applying a correcting factor :
factor = dpiPrinter/dpiScreen
X1 /= factor
...
I get these dpi with pDC->GetDeviceCaps(LOGPIXELSX); for the printer it can be
75 ... 1200 dpi, and for screen it is 96.
On paper there was still a error of about 4 %; for example when I printed a bitmap whose
width was expected to be 50 mm, I got 48 mm on paper.
I have tested many hypotheses, including playing with Graphics.SetPageUnit(), Graphics.SetPageScale(), ... And finally an intuition, nothing rational but after all I was ready for black magic : an error of 4 %, OK let's say my dpiScreen is 100 and not 96... size and position are now perfect, for any printer resolution.
I assume that the LOMETRIC mapmode is in cause; as the logical units are not pixels, the screen resolution returned by GetDeviceCaps() is not relevant anymore; but then how do work the factor dpiPrinter/100 ? I have not tested yet with another mapmode, for example HIMETRIC (.01 mm). I guess (?) that my 100 would have to be replaced by 1000.
I can survive without understand that, but if someone has explanation...
|
|
|
|
|
hi guys(and gals),
I have this 2 port nic installed. Bridging the 2 nic ports I have a crossover cable. What i'm looking to do is be able to send data out on one port and have it read in by the other. However on this basic app I wrote it will connect(bind is a better term) to each static ip on the nic; one to send, the other to receive. I chose to use port 3344(no specific reason). Once I connect i send a simple 2 mb file. The transfer works just fine. The problem I encounter is that the transfer is not going thru the crossover cable but somehow routed internally; telling me the os(nt4 server) knows the ip's are internal and not to send the data out across the crossover cable. What i'm looking to do is force the data out across the crossover cable.
if it helps these are the ip's assigned:
192.168.0.1
192.168.0.2
thanks
|
|
|
|
|
I don't think its the O/S that is doing it to you. More likely its the nic card itself (or maybe its driver). You can test this by installing a second nic.
|
|
|
|
|
Thanks for the tip. I just installed a second nic and still get the same results. file transfer between the 2 ports still goes smooth even without the crossover attached
Eric
|
|
|
|
|
Wow, that is surprising. Fraid that's all I had to offer.
Good Luck
|
|
|
|
|
Thank you for your help nonetheless.
|
|
|
|
|
I know there exists a function in C++ which you pass a filename. The function then uses the program defined in Windows for that type of file to open the file.
I don't know if this is the right place to ask, but I try anyway. So if you understand the above and know which function I mean or where to find it, please mail me. Thanks a lot.
|
|
|
|
|
|
Have you made some experience with Active Directory ?
If you do so, then please let me know because i have some problems with ADSI!
|
|
|
|