|
By explicitly setting some of the parameters to WriteProfileString () to NULL , you accomplish the "delete" function. See the documentation[^]
|
|
|
|
|
Thank you.
I need to quit relying on my 2001 MSDN and check the web site more often.
|
|
|
|
|
I am writing a dialog box using VS resource editor. In the dialog, I put a search control that is expected to be the same as IE8's search box: a line edit control and a BS_OWNERDRAW style push-button control sitting side by side. I use the bitmap file Search.bmp in VS2008ImageLibrary directory. My problem is the bitmap is not drawn transparently. It's pink background is drawn on the button. This takes on an ugly apperance. How can I remove the pink background? Here is code I use to draw the bitmap:
case WM_INITDIALOG:
// Load image for search button
hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_SEARCH));
case WM_DRAWITEM:
LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)lParam;
HDC hDC = lpDIS->hDC;
RECT rectItem = lpDIS->rcItem;
// Draw the bitmap on button
if ( hBitmap != NULL ) {
RECT rcImage;
BITMAP bm;
LONG cxBitmap, cyBitmap;
if ( GetObject(hBitmap, sizeof(bm), &bm) ) {
cxBitmap = bm.bmWidth;
cyBitmap = bm.bmHeight;
}
// Center image horizontally
CopyRect(&rcImage, &rectItem);
LONG image_width = rcImage.right - rcImage.left;
LONG image_height = rcImage.bottom - rcImage.top;
rcImage.left = (image_width - cxBitmap)/2;
rcImage.top = (image_height - cyBitmap)/2;
DrawState(hDC, NULL, NULL, (LPARAM)hBitmap, 0,
rcImage.left, rcImage.top,
rcImage.right - rcImage.left,
rcImage.bottom - rcImage.top,
(bIsDisabled ? DSS_DISABLED : DSS_NORMAL) | DST_BITMAP);
}
|
|
|
|
|
Does the bitmap have an alpha channel (or it uses a colorkey for transparency)? Whichever it is, does DrawState support it (can't see that in its documentation).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Hi, I am not sure if the bitmap has alpha channel or not. It is indeed the file C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\VS2008ImageLibrary\1033\VS2008ImageLibrary\Objects\24bit_bitmaps\search.bmp. Would you please take a look at this file if you have VS 2008?
|
|
|
|
|
Hi,
Typically when you see those pink RGB(255,0,255) chroma key backgrounds... the pink is designated as the 'transparent' color. Supposedly a statistical analysis of random images determined that pink is the least used color. I can't remember where I read this, I think I heard it from Feng Yuan.
Anyway, you are probably looking for the TransparentBlt function[^] and pass RGB(255,0,255) as the crTransparent argument.
Since you are using a BS_OWNERDRAW style push-button... and the DrawState function [^] you would probably need to set the DST_COMPLEX flag and implement a DrawStateProc callback function[^] and inside that function call TransparentBlt[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you very much, I'll try your method today.
|
|
|
|
|
I replace DrawState with TransparentBlt and it works. Thanks again.
|
|
|
|
|
Transparencies are not supported.
You'll have to fake it.
|
|
|
|
|
It needs to display remote disk info in Application. So I should get the driver icon, but I do not know how to get the driver icon.
I use the API SHGetFileInfo to get file icon and folder icon, But I do not know how to get the Driver icon.
I try to get driver "c:\" icon index and set to CTreeCtrl, but if there is no C disk in computer, error happens.
|
|
|
|
|
yu-jian wrote: if there is no C disk
The system partition can be derived from several of the environment variables, ProgramFiles being one of them.
|
|
|
|
|
You can use deleaker or similary tool for search memory leaks.....
|
|
|
|
|
Sorry, what?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I use cork plug to stop a leak.
Is that OK?
|
|
|
|
|
I'm building a simple editor in a CFrameWnd using a CRichEditCtrl for the text.
As a stand-alone application everything works.
When I put the same frame code into a regular DLL, most things still work, but all custom accelerators don't function (things like Ctrl-V, Ctrl-C, etc. which are handled by the CRichEditCtrl do).
I've been able to recreate this same problem with the CMainFrame code generated by the Visual Studio Wizard.
Does anyone have any suggestions?
NciTom
|
|
|
|
|
Hi,
May be the following link will help you.
http://social.msdn.microsoft.com/Forums/en-US/vcmfcatl/thread/8bbdbd37-8034-4489-bd86-2351f0febb37
Cheers
|
|
|
|
|
Thanks Satheesh,
Unfortunately the link you suggest is one that I started in MSDN. Since it didn't get resolved there, I tried this forum.
|
|
|
|
|
Try to change the regular dll to MFC extension dll.
|
|
|
|
|
Patup,
Thanks,
Easier said than done.
I took the trivial mainfrm code from a wizard generated single document app and massaged it into an extension DLL. I can get it to compile, but it traps during the load of the MainFrm window.
Does anyone know of an example of an extension DLL that loads a CFrameWnd?
|
|
|
|
|
ncitom wrote: I took the trivial mainfrm code from a wizard generated single document app and massaged it into an extension DLL.
Based on your brief description... it sounds like something related to either activation context[^] or the MFC module state[^].
I would be willing to have a look at your test case if you could put it up somewhere where I could download. However I offer no guarantees.
Best Wishes,
-David Delaune
|
|
|
|
|
David,
I must have put a typo into my program somewhere. I started over and successfully made an extension dll that works (albeit just a trivial version of my project).
It also seemed to solve the accelerator problem. Hopefully that's the answer to quite a few issues I've seen with MFC in a DLL.
Thanks,
Tom Wanat
|
|
|
|
|
Tom,
That's great to hear. Feel free to come back if you have any other problems. It's amazing that after you joined the codeproject that you were able to remain silent for 8 years, 8 months. Hopefully we will hear back from you before another 8 years pass.
Best Wishes,
-David Delaune
|
|
|
|
|
David,
I have visited codeproject many times during that period. I think of it as one of the most reliable sources of information.
I don't usually ask questions until I've exhausted other avenues, and I don't feel that confident to offer my experience.
Thanks for noticing,
Tom Wanat
|
|
|
|
|
I build a dynamic menu "system" based on a hierarchy of files and folder (based on the MFCIE sample on msdn).
When I add my item to the menu I do something like :
CString menuString("my menu entry");
pMenu->AppendMenu(MF_STRING | MF_ENABLED, menuID, menuString);
In the CMainFrame::OnCmdMsg I handle the CN_COMMAND and CN_UPDATE_COMMAND_UI messages to handle the commands associated to the menu entries.
That is working fine.
Now, I'd like to be able to display a message in the status bar when the user moves the mouse over the menu items.
normally on "static" menu , I set the menu string (including mnemonic) in the resource and add an associated STRINGTABLE entry for the menu ID :
...
MENUITEM "DoSomething\tF5", ID_DO_SOMETHING
...
STRINGTABLE
BEGIN
ID_DO_SOMETHING "Do Something\nMEssage that explains DoSomething"
END
-----
Is there an API to do that ? As far as I can see and read in MSDN there's nothing for it.
Or what should I do to do this "manually" ? I assume I have to do some kind of mouse tracking (and onIdle or timer?) to get the menu item and post a relevant text to the status bar.
Thanks.
Watched code never compiles.
|
|
|
|
|
Havn't done it myself, does CStatusBar[^] MFC class of any help?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|