|
The signature for the message handler is wrong, it should be
LRESULT CSVBoxView::OnUDMUpdateDisplay ( WPARAM wParam, LPARAM lParam ) the sig used for any generic message handler. It's crashing because PostMessage() puts two parameters on the stack, but the function only removes one, so when the function returns it doesn't read its return address off the stack correctly.
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I am so glad to get your response> That indeed was it> I cant thank you enough!!!!
Appreciate your help,
ns
|
|
|
|
|
Michael Dunn, beat me to it. A similar problem was one of my first ' pain in the neck ' bugs, when I was still a newbie. The sigs for message handlers have to be correct in release mode, but usually sail through in debug mode without complaint
"Life begins at 140"
|
|
|
|
|
Hi There,
Let's say I've got an MFC MDI app with three child frames open. How do I figure out which one is the active one?
Thanks,
Aaron
|
|
|
|
|
CFrameWnd supports a function called GetActiveView(). This should work for your purposes.
|
|
|
|
|
Hi All,
I'm creating a toolbar and I have a couple of questions:
1) when setting up a button on a tool bar to be multiple state (i.e. start/stop) and I want to change the bitmap displayed on the button, how do I change the bitmap on the button? And does this bitmaps need to be inserted as an icon or do they both need to be on the toolbar itself? If that is the case, would I have to make two seperate buttons and then hide the one that isn't the current state?
2) Is there a general place to find groups of generic button bitmaps or do I need to make my own?
thank you in advance. I appreciate all the help I have gotten here in the past and in the future.
Thanks.
Dan Willis
|
|
|
|
|
Hello,
Hopefully this helps...
groover4life wrote:
1) when setting up a button on a tool bar to be multiple state (i.e. start/stop) and I want to change the bitmap displayed on the button, how do I change the bitmap on the button?
The following code should help.. I create a function so that if a button is pressed and the bitmap needs to be changed.. change the bitmap for the whole tool bar (to either ON or OFF).. if a button is pressed and you dont need to change the bitmaps don't run the following... You get the idea..
You will need to create 2 bitmaps for the tool bar.. one for "ON" and one for "OFF".. both these bitmaps need to be in your resoruces tab..
HIMAGELIST hOld = (HIMAGELIST)::SendMessage(m_wndToolBar, TB_GETIMAGELIST, 0, 0);
ImageList_Destroy(hOld);
CImageList imageList;
CBitmap bitmap;
bitmap.LoadBitmap(IDB_OFF); <-- BITMAP IN RESOURCE
imageList.Create(16, 16, ILC_COLORDDB|ILC_MASK, 3, 1);
imageList.Add(&bitmap, RGB(255,0,255));
m_wndToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
imageList.Detach();
bitmap.DeleteObject();
HIMAGELIST hOld = (HIMAGELIST)::SendMessage(m_wndToolBar, TB_GETIMAGELIST, 0, 0);
ImageList_Destroy(hOld);
CImageList imageList;
CBitmap bitmap;
bitmap.LoadBitmap(IDB_ON); <-- BITMAP IN RESOURCES
imageList.Create(16, 16, ILC_COLORDDB|ILC_MASK, 3, 1);
imageList.Add(&bitmap, RGB(255,0,255));
m_wndToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
imageList.Detach();
bitmap.DeleteObject();
groover4life wrote:
2) Is there a general place to find groups of generic button bitmaps or do I need to make my own?
I'm sure you can find them some where.. I usually just make my own..
Hope this helps..
Rob
|
|
|
|
|
This helps.
BUT, if I have ... say ... 10 buttons that each have 2 functions to them (I don't, but just an example) I'd have to have a TON of bit maps just for that 1 tool bar. There's gotta be a more efficient way to do it. In my case this would work becuase I only have a couple of buttons, which would mean I'd have to have 4 different bitmaps I'd have to load depending on the state I'm in.
Thanks!
Dan Willis
|
|
|
|
|
Yep your right.. The example I provided was based on how to change the bitmap for all buttons on the toolbar (not very usefull in your example).. I know there are articles here on codeproject and on codeguru that will show you how to do just what you are trying to do..
Rob
|
|
|
|
|
Ok, here comes a real hack that does work, but once implemented you will not be able to change your toolbar using the toolbar resource editor, so make sure you have all your buttons set up in their default states first.
1.) Using MSPaint (or another graphics editing tool) extend the toolbar bitmap by adding the new bitmaps you want to the end of it. remember to make all the images the same size (default is 16 x 15 pixels)
2.) to the class that will handle the button states, add an integer variable that will keep track of which bitmap is currently displayed on each button (use seperate variables or an array of them). The variable will hold the index number of the image in the bitmap. remember that the first image in the bitmap is at index 0 not 1.
3.) add an ON_COMMAND message handler for the button being clicked. in that handler, change the index variable to contain the index of the new image
4.) add an ON_UPDATE_COMMAND_UI handler for the button. here you check if the command is coming from the toolbar (as opposed to the menu), and then you use CToolBar::SetButtonInfo() to change the image.
CMyView::OnUpdateAppAbout(CCmdUI* pCmdUI)
{
if (pCmdUI->m_pOther && pCmdUI->m_pOther->IsKindOf(RUNTIME_CLASS(CToolBar)))
{
CToolBar *pTB = (CToolBar *)pCmdUI->m_pOther;
pTB->SetButtonInfo(pCmdUI->m_nIndex, pCmdUI->m_nID, TBBS_BUTTON, m_nAboutImage);
}
}
although you may want to use CToolBar::GetButtonInfo() to get the button style
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Actually i need to colour different rows of CListView by different colours...so how to do this?
Any Help ...
Thanks
|
|
|
|
|
You could derive your own class from CListView and make it owner-drawn, then implementing DrawItem().
|
|
|
|
|
|
BTW your article on NM_CUSTOMDRAW was probably the most useful article to me on CodeProject. I didnt know about NM_CUSTOMDRAW at all when your article was first posted.
It saved me a lot of bother at work. Our product needed editable list controls all over the place and at the time I was looking at writing an owner draw CListCtrl derived class from scratch to mimic something like the grid class which is here on codeproject. But simply rewriting all our list control code using the excellent but pretty heavyweight grid class was too much grunt work and I wasnt looking forward to writing an owner draw one either. But I was able to write a pretty lightweight editable CListCtrl using customdraw. It's almost as good as the grid class for our purposes with a lot less effort.
"Life begins at 140"
|
|
|
|
|
Thanks Bill! Or... should I call you ~Bill
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
So I have this application that does some data manipulation within a worker thread, and during lengthy operations, I like to post messages and update the GUI accordingly. Currently I am using custom WM_USER messages and using SendMessage() to the main thread. As I understand, SendMessage will wait for the message handler to return before going on, whereas PostMessage keeps on going. Also, I hear WM_USER is kinda outdated... Anyway, what is the best method of posting messages to update a gui from a worker thread that will avoid deadlocks or any messy stuff??
Thanx again!
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
|
Now why didn't I see this when I looked...
Thanx PJ!
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
How can I obtain the current working directory of my application? Note: The application isn't installed nor does it keep any info in the registry. It also may or may not be called by another application (which alters the working directory somehow).
I ask because I have a data file I want to read in at runtime, and using ".\MyFile.dat" will work when I run the app within it's own directory, but when the other app calls it, ".\" is some other directory.
Thanks!
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
GetCurrentDirectory() gets the current directory ( I guess you've found that )
If you want to find the location from where the app is running (i.e. the location of the .exe), you can call GetModuleFileName(), and strip off the actual filename to leave the path.
Hope this helps!
|
|
|
|
|
Martyn Pearson wrote:
you can call GetModuleFileName(), and strip off the actual filename to leave the path.
Hope this helps!
sweet!
You 'da man! Thx!
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Basically, when you insert an item into a tree, you do something along the lines of
HTREEITEM hMyItem = pMyTree->InsertItem(&lvTreeItem);
Is it ever possible that the value of hMyItem will change throughout the lifetime of the tree?
My reason for asking is that I have an object for each item in the tree, and I would like to maintain the handle within the object so that changes to it can be reflected easily in the tree (i.e. by changing the icon etc)
Thanks in advance!
|
|
|
|
|
Martyn Pearson wrote:
Is it ever possible that the value of hMyItem will change throughout the lifetime of the tree?
As far as I know a handle to a tree item should be valid during whole lifetime of the tree. I can't guess any situation in which the handle could be changed - especially as you can use it on any time for further operations like deleting, ...
|
|
|
|
|
Martyn Pearson wrote:
Is it ever possible that the value of hMyItem will change throughout the lifetime of the tree?
No, if that happened then HTREEITEM s would be useless.
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Where can I find guide about using Microsoft ADO Control(
like ADO DataCombo,DataList...).
Thank You
|
|
|
|