|
Anonymous wrote:
WM_MOUSEMOVE is the message I was hoping to handle.
Oh, well that's sent directly to your button anyway, so you should have no problem handling it in your CButton -derived class. The only thing i can think of that might get tricky with this would be if you wanted to know when the mouse was moved outside of the button, since you'll no longer recieve messages then. Two solutions to this are mouse capture (if the user will be holding a mouse button down) or setting a timer and periodically checking the mouse position (appropriate for "hot tracking", etc.).
--------
People they come together
People they fall apart.
No one can stop us now
'cause we are all made of stars... -- Moby, We are all made of stars
|
|
|
|
|
Hmmmm
Actually it's a CBitmapButton derrived class, but I don't believe that would matter.
This is how I created it in the view class
fbOpen.Create(_T(""), BS_OWNERDRAW, rect, GetSafeOwner(), IDC_NEW_BUTTON)
and this is my message handler in my derrived class
void CBitmapFlipButton::OnMouseMove(UINT nFlags, CPoint point)
{
AfxMessageBox("The Mouse has moved, Yahoo !!",
MB_OK);
CButton::OnMouseMove(nFlags, point);
}
Please let me know if something is wrong. Otherwise I will keep searching for an example.
Thank you for you time shog, and every one else posting.
|
|
|
|
|
Anonymous wrote:
and this is my message handler in my derrived class
And it isn't getting called? Check the message map i guess, otherwise it looks fine.
--------
People they come together
People they fall apart.
No one can stop us now
'cause we are all made of stars... -- Moby, We are all made of stars
|
|
|
|
|
Figured it out with spy++
Didn't get any WM_MOUSEMOVE messages until the cursor was over the titlebar.
Changed the buttons create function to use the this pointer inplace of GetParent() for the pParentWnd parameter and it seems to be working. Hope there are no side effects.
|
|
|
|
|
|
why ReleaseDC is not saving my information.
|
|
|
|
|
[edited - my brain works faster than my fingers]
ReleaseDC() does not save information. Please provide more info.
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
If a man is standing in the middle of the forest speaking and there is no woman around to hear him...is he still wrong?
|
|
|
|
|
I'm making a window that acts as a menu, see:
this is my command:
ShowMenu(BOOL bFromKey, int x, int y,CWnd* pParent, HMENU hMenu)
and i have a CMenu named m_pMenu
i convert the hMenu into a CMenu:
m_pMenu->m_hMenu = hMenu;
this is ok, now i create my window using the CreateEx command, after my window is created i call another class called DrawMenuItem, this one get the size of all the menuitems stored in the m_pMenu, after get the size of the items, i assing the size to the window using the MoveWindow, after this the window is showed using the ShowWindow, then i call the ReleaseDC to make m_pMenu free for use for every class, but here's the problem when the menu is showed it call the OnPaint, in this i paint the background and i draw the menu text for the menuitems, but the m_pMenu is empty in this, why if it's supposed to be the m_pMenu of the ShowMenu command?
|
|
|
|
|
So let me get this clear, you are painting the background and text in the menu, but ...
A) you never see the text appear on the menu
B) you see the text appear on the menu, but the next time it appears the text is gone
First, I would say that if you are painting the background in the OnPaint handler, then you need to handle the OnEraseBkgnd handler as well and simply return TRUE in your implmentation of this function.
second if your answer to the above statement is choice A, I would say make sure that you are drawing in the proper coordinates for you window. It is possible that you have miscalculated the region that you should be drawing and you are not drawing on a region where the menu window exists.
If your answer is B, then I will have to ask some more questions.
Good Luck!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
If you want the data for a DC from a window to be persistent after you call ReleaseDC, then you need to create your window with the CS_OWNDC or CS_CLASSDC style.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
is not working either
|
|
|
|
|
Based on your reply to PJ Arends response, the styles of your window are not the problem. I responded to the other thread, I hope that helps you.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I have this combobox that i want to add some items to, but nothing is added when i do this:
for (int i = 0;i < 147;i++)
SendMessage(DlgItems[5], CB_ADDSTRING, 0L, (LPARAM)gszGenres[i]);
DlgItems[5] equals the hwnd of the control and gszGenres is a global char array with 148 items.
WHat am i doing wrong?
thanks
|
|
|
|
|
I just did what you're trying to do, but you don't mention a few things so I had to improvise in my declarations.
Here's how I declares my array of HWNDs
static struct
{
int id;
} combos [] = {
IDC_COMBO1, IDC_COMBO2, IDC_COMBO3, IDC_COMBO4, IDC_COMBO5, IDC_COMBO6};
HWND DlgItems[6];
I then initialize them like this:
for (int i = 0; i < sizeof combos / sizeof combos[0]; i++)
DlgItems[i] = ::GetDlgItem(GetSafeHwnd(), combos[i].id);
I created an array of strings like this:
static struct
{
char sz[10];
} gszGenres [] = {
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
"21", "22", "23", "24", "25", "26", "27", "28", "29", "30",
"31", "32", "33", "34", "35", "36", "37", "38", "39", "40",
"41", "42", "43", "44", "45", "46", "47", "48", "49", "50",
"51", "52", "53", "54", "55", "56", "57", "58", "59", "60",
"61", "62", "63", "64", "65", "66", "67", "68", "69", "70",
"71", "72", "73", "74", "75", "76", "77", "78", "79", "80",
"81", "82", "83", "84", "85", "86", "87", "88", "89", "90",
"91", "92", "93", "94", "95", "96", "97", "98", "99", "100",
"101", "102", "103", "104", "105", "106", "107", "108", "109", "110",
"111", "112", "113", "114", "115", "116", "117", "118", "119", "120",
"121", "122", "123", "124", "125", "126", "127", "128", "129", "130",
"131", "132", "133", "134", "135", "136", "137", "138", "139", "140",
"141", "142", "143", "144", "145", "146", "147", "148"};
Finally, the code to load the combo box:
for (int i = 0; i < sizeof gszGenres / sizeof gszGenres[0]; i++)
::SendMessage(DlgItems[5], CB_ADDSTRING, 0L, (LPARAM)gszGenres[i].sz);
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
I don't use all that MFC stuff. Do you know how to do it without MFC? here's what i do:
HWND DlgItems[6];
DlgItems[5] = GetDlgItem(hWnd, IDC_GENRES);
and then initialize the strings like this (up to number 147)
char gszGenres[148][23];
strcpy(gszGenres[0], "Blues");
strcpy(gszGenres[1], "Classic Rock");
strcpy(gszGenres[2], "Country");
strcpy(gszGenres[3], "Dance");
... etc.
and then add them like a wrote before...
|
|
|
|
|
What MFC stuff? I defined two static structs, called the Win32 SDK function ::GetDlgItem to fill the hwnd struct and then called the Win32 SDK function ::SendMessage to send the CB_ADDSTRING message. The only MFC you see here is the call to GetSafeHwnd becuase I don't know from where you're calling the ::GetDlgItem function. You can obviously replace that with however you get the hwnd for your dialog.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
Oh, sorry, i see, we're doing exactly the same... does your work?
|
|
|
|
|
No problem. My app is an MFC app, but I'm using Win32 SDK calls to mimic your environment. Yes, the data shows up exactly as it should.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
Then i simply don't understand it. I have also tried just passing (LPARAM)"hello" to the lparam, and nothing happens...
|
|
|
|
|
strange, when i use the CB_GETCOUNT message to get the number of items in the combobox, it says 147, but nothing shows up in the box...
|
|
|
|
|
When i send the WM_SETTEXT message and pass for example "Rock" to the lparam, it selects it and it appears...
|
|
|
|
|
I just checked if my WndProc recieved the CBN_DROPDOWN message (the message sent when the list is about to be expanden ie. dropped down) and it doesen't get the message...
|
|
|
|
|
What happens when you do a CB_SETCURSEL?
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
It works "Acid Punk"... number 3...
|
|
|
|
|
This tells me that your drop down is too small.
Sorry. I just read how that can be taken.
Anyway, this thread should help you in determing how to, er, lengthen your drop down.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|