|
Agreed, CBitmap*s is the way to go in this specific case.
I recently tried to use the MS auto_ptr and failed miserably because it doesn't implement reset(). Instead I used boost::scoped_ptr to very good effect. I plan to use it more in the future. Worth a look.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
No, thanks for your help! I didn't like auto_ptr in the past and I will go back to my old code with CBitmap*
|
|
|
|
|
Probably the problem comes from HBITMAP , which is a handle and can't be simply "copied". If you simply copy the value of the HBITMAP , you would create a reference... which would become invalid if the original HBITMAP fades away.
I guess a CBitmap copy-ctor has to test 1. HBITMAP to be valid and 2. create a new handle by duplicating the original.
I don't know if this is possible with Win32. Perhaps not or CBitmap would already do it? Comments?
PS: Using auto_ptr of *CBitmap (rathern than CBitmap) seems to be a solution.
|
|
|
|
|
Hi,
Can anyone tell me how to make the enter key work like a tab key in a dialog box.
For instance, I have two edit controls, a Checkbox control and three command button controls and I pressing the enter key should setfocus to the next control according to the TAB order.
Is it possible to do this without using event handlers for each and every control?
Regards,
Seagull.
|
|
|
|
|
PreTranslateMessage
How low can you go ? (MS retrofuck)
|
|
|
|
|
|
Hi.
I am implemented a very simple MFC program without the powerful of ClassWizard.
I added a CListCtrl listbox. Everything works as designed except for a double-click message handler. I cannot get the program to respond when the user double-clicks the listbox. I have tried different messages, but all failed.
I would like to know, What message do you handler for double-click (left mouse button) on a CListCtrl that is not in a dialog box and was not implemented using ClassWizard.
Thanks,
Kuphryn
|
|
|
|
|
Your dialog box receives the LBN_DBLCLK notification message when you double-click. You can add a command handler ON_COMMAND(LBN_DBLCLK, ...) in your parent window.
How low can you go ? (MS retrofuck)
|
|
|
|
|
Okay. Thanks.
The program ignores all solutions yet. There is something weird going on here. I try adding a hander for LBN_DBLCLK and it only works outside of the CListCtrl box. I believe the program ignores everything inside of the list box.
Kuphryn
|
|
|
|
|
kuphryn wrote:
I believe the program ignores everything inside of the list box.
The notification is sent TO THE PARENT WINDOW, that's by design.
Otherwise, you need to derive your own class, and tweak things a bit (many CP articles are here to help your way out).
How low can you go ? (MS retrofuck)
|
|
|
|
|
You're confusing the list box and list control. CListCtrl is the latter, and sends an NM_DBLCLK message to its parent when the control is double-clicked.
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Okay.
NM_DBLCLK does not work either.
I tested ON_NOTIFY and ON_NOTIFY_REFLECT using NM_DBLCLK and LBN_DBLCLK.
Kuphryn
|
|
|
|
|
Okay. I figured out the bug. The bug was a human-error, not an MFC error.
I made an error during creation of the CListCtrl object.
Here is the error.
// Here is the incorrect creation code.
-----
m_LB_Box.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SORTASCENDING, CRect(0, 100, 100, 50), this, 1);
-----
Notice the "1" in the last parameter.
// Here is the solution.
-----
m_LB_Box.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SORTASCENDING, CRect(0, 100, 100, 50), this, IDC_LB_BOX);
-----
Thanks everyone,
Kuphryn
|
|
|
|
|
How can i open a default internet browser in new window ???
|
|
|
|
|
Use the opennew verb, intead of open.
How low can you go ? (MS retrofuck)
|
|
|
|
|
ShellExecute("open", "http:\\www.copdeproject.com", NULL, NULL, SW_SHOW);
|
|
|
|
|
Hey all. I'm working on a MFC Single Doc program. I have included:
<br />
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);<br />
m_pMainWnd->UpdateWindow();<br />
It is maximizing the program correctly. My problem is that when it loads, it is not the active program. Any help on how to fix this is appreciated.
Brad Jennings
|
|
|
|
|
|
Thanks a lot. Not exactly what I was looking for but the answer wasn't far off. I just needed to add the line:
<br />
m_pMainWnd->SetForegroundWindow();<br />
Later.
Brad Jennings
|
|
|
|
|
Hello, can anyone tell me how to minimize a dialog box programatically to
the system tray on start up. Like MSN messanger or ICQ.
Thank You
|
|
|
|
|
if you want a taskbar icon, see http://www.codeproject.com/shell/cjbtaskbarapplet.asp
-c
Alcohol is the anesthesia by which we endure the operation of life.
-- George Bernard Shaw
|
|
|
|
|
It crashes at the update().I checked to see that there was valid data in in the fields after being assigned.
while (!m_db1.m_pRecordset->GetadoEOF ())
{
m_db3.Open(DatabaseName3);
int n = m_db3.m_pRecordset->RecordCount;
m_db3.m_pRecordset->AddNew();
std::set<CString>::iterator itA = m_set3.begin();
for(; itA != m_set3.end(); itA++)
{
tempStr = *itA;
char* fldIt1 = new char [tempStr.GetLength() + 1];
strcpy(fldIt1, tempStr);
CString strTemp((char*)(_bstr_t)(m_db1.m_pRecordset->Fields->Item[fldIt1]->Value));
m_db3.m_pRecordset->Fields->Item[fldIt1]->Value = m_db1.m_pRecordset->Fields->Item[fldIt1]->Value;
;
delete[] fldIt1;
}
m_db1.m_pRecordset->MoveNext();
m_db3.m_pRecordset->Update();
m_db3.m_pRecordset->Close();
m_db3.m_pRecordset = NULL;
m_db3.Close();
}
|
|
|
|
|
You have MoveNext before the Update.
|
|
|
|
|
Thanks. But actually thats the movenext for a different database. I'm cycling through 1 and adding to another.....but thank you anyway
ns
I did find my problem a few minutes ago (hurrah!). I had added and populated a field in the new databse, but didnt realize I had to close and reopen it for the change to be visible to the program. Once I did that things are going along fine!
|
|
|
|
|
nss wrote:
Thanks. But actually thats the movenext for a different database. I'm cycling through 1 and adding to another.....but thank you anyway
ns
Ooops.
nss wrote:
I did find my problem a few minutes ago (hurrah!). I had added and populated a field in the new databse, but didnt realize I had to close and reopen it for the change to be visible to the program. Once I did that things are going along fine!
Which database are you using, and what version of ADO? I had a similar problem with an Access 97 database, with the field not updating unless I closed and reopened the recordset. It turned out to be a bug in the Jet driver for 97, so moving to Access 2000 DB fixed it, so that when I called update the correct value was there.
|
|
|
|