|
Why don't you access the database from within the dialog box? You can create a worker thread that runs the timer, and another worker thread that actually accesses the database and that sends a message back to the dialog that tells the dialog to refresh the list.
In fact, the app should be a dialog based app if that's all it does.
I wrote a series of articles that includes a part that describes a similar process.
http://www.codeproject.com/samples/SDIMultiSplit_Part3.asp[^]
The threading stuff is about halfway down the page, and the classes I included in the demo source code should be easily modifiable to fit your needs. Nothing is free, so be prepared to try to figure this stuff out on your own (because only YOU know all of your requirements). You'll learn more that way. I can say that the timer thread should be a direct drop-in in your code. You also don't have to worry about the status bar panes, so passing a NULL in for the timer thread for that parameter should be fine.
Have a ball.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thank you very much, i'll do whatever it takes to get this app to work like i want it to, i've started from scratch in c++ last month because of the app having to be in c++, been a ball all the way I'll have a read through the article too.
Only sometimes i feel like
Getting easier though.
Thanks very much for the help.
|
|
|
|
|
XTr1NiTy wrote: Im trying to send messages to a main dialog,
From where? It's just asking for trouble to update a UI control from someplace other than the owner. If you have another class or thread that needs to update the control, it's better to post a message to the owner of said control (i.e., main dialog).
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thx , ill try PostMessage, havent tried that yet.
Its from an external class using the database rows to display the data.
|
|
|
|
|
You have two problems:
1. You're casting a CListBox* to an HWND . This will not work because they are not the same thing.
2. You're sending the wrong messages. A list box doesn't understand list control messages.
|
|
|
|
|
hi
how do i disable a submenu item when i select another submenu item?
thanks
|
|
|
|
|
SEE the Sample code..............
Please modify the code as per your project.
CMenu *mnuPop;
mnuPop->LoadMenu(IDR_TASKBAR_MENU);
SetForegroundWindow();
CWnd* pWnd = AfxGetMainWnd();
if(pWnd->IsIconic() != 0) // minimized
{
mnuPop->GetSubMenu(0)->EnableMenuItem(ID_WJRU_WJRU,MF_BYPOSITION | MF_ENABLED);
}
else
{
mnuPop->GetSubMenu(0)->EnableMenuItem(ID_WJRU_WJRU, MF_BYPOSITION | MF_GRAYED);
}
|
|
|
|
|
thanks for the help. but i am actually writing for a menu bar and when i click on a submenu item another submenuitem should get disabled. hope u're getting what i am trying to do.
|
|
|
|
|
May be this will help you..
//This Code is Written in sub - submenu
// Your First Menu.
CMenu *mnuPop;
// Your Second Menu.
CMenu *mnuSubMenu;
// Load your menu here...
mnuPop->LoadMenu(IDR_THERMATYPE);
// Get the Sub Menu handle handle here...
mnuSubMenu = mnuPop->GetSubMenu(0);
// Disable the Another Submenu from this Sub Menu...
mnuSubMenu->EnableMenuItem(ID_EDIT_COPY,MF_BYPOSITION | MF_GRAYED);
// Redraw your Menu after this.(only some times needed...
|
|
|
|
|
this gives an error in this line
mnuSubMenu = mnuPop->GetSubMenu(0);
i tried this out:
CMenu popmenu;
popmenu.EnableMenuItem(ID_CONFIGURE_UPDATE,MF_GRAYED);
in the on click of the submenu item. but this gives a crash for me
|
|
|
|
|
Is mnuPop valid and what return values of mnuSubMenu
|
|
|
|
|
Sunshine Always wrote: how do i disable a submenu item when i select another submenu item?
you cannot hide/unhide teh menu item on runtime.. except if you creating menu on runtime.. you only can disable and enable the menu item
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
HI
I read unicode string in str(TCHAR *str).How can i convert it into ascii.
|
|
|
|
|
You mean something like W2A() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
knowing that he's using TCHAR string, i'd say T2A() instead
|
|
|
|
|
asdtry wrote: I read unicode string in str(TCHAR *str).How can i convert it into ascii.
wcstomcs
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
I've created a menu called Tools where in I have created a menu item called Preferences. If we click the Prefernces menu item Preferences Dialog Box will open. In that Dialog Box I have an edit box. The message entered in this edit box is displayed in the second panel of the status bar (i.e) panel no.1.
My Requirement is:
The second panel should be of a default size and it should grow according to the length of the message entered in the edit box.
How can I achieve this in MFC? Can any one help?
|
|
|
|
|
Use
CStatusBar::SetPaneInfo( int nIndex, UINT nID, UINT nStyle, int cxWidth );
|
|
|
|
|
you just need to do it as follows:
void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI)
{
CString strValue;
strValue.Format("%s", message.GetString());
pCmdUI->Enable(TRUE);
pCmdUI->SetText(strValue);
CDC* pDC = m_wndStatusBar.GetDC();
CSize mSize = pDC->GetTextExtent(strValue);
m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_NORMAL, mSize.cx);
}
freeman
|
|
|
|
|
void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI)
{
char str1[150];
CString strValue;
//strValue.SetLength(100);
strValue.Format("%s", message.GetString());
//sprintf(str1, "%s",message.GetString());
pCmdUI->Enable(TRUE);
pCmdUI->SetText(strValue);
CDC* pDC = m_wndStatusBar.GetDC();
CSize mSize = pDC->GetTextExtent(strValue);
m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_NORMAL, mSize.cx);
//m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len);
}
When I add this code I got an exception stating ,
'Unhandled exception at 0x7c1d71bb (MFC71.dll) in Perspective.exe: 0xC0000005: Access violation writing location 0x00000014.'
When I break this exception, it ends in a class barstat.cpp which is not created by me.
Also this exception occurs only when we add the status bar variable(m_wndStatusBar) to this class CPerspectiveDoc.
The Status Bar Pane is created in some other class.
How to resolve this?
Pls help
-- modified at 4:01 Tuesday 6th February, 2007
|
|
|
|
|
Oh, dear friend, I think u've made a mistake! In my opinion, the CDoc class in your project is constructed before the CMainFrame class, and the status bar is created in Oncreate() function of the CMainFrame class. So, you'd used a status object before you created it. Am I right?
OK, U can resolve this by many methods.there r 2 simple resolutions follow:
1. U can do this in the CMainFrame class after the status bar object is created.
2. U can do it in the CView class as the same.
-- modified at 4:36 Tuesday 6th February, 2007
freeman
|
|
|
|
|
Hello,everyone! I want to ask a question about my practice. I created some string entries in the string table such as IDS_STRING1,IDS_STRING2,IDS_STRING3... .Now, I want to load one of them for the CString object by a string I specified. for example, the string I specified was "IDS_STRING1" , how can I convert "IDS_STRING1" to the right Resource ID? Thank u so much!
freeman
|
|
|
|
|
i'm not sure at all to understand what you want.
if i'm right, you want to get the actual string behing the string ID in the resource string table.
for this, 2 solutions :
CString::LoadString()
or
CString::Format()
|
|
|
|
|
Thank u for your reply, I wish u a good day!
freeman
|
|
|
|
|
See if this answers your question....
Answer 1:
CString Str;
Str.Format(IDS_STRING1);
Answer 2:
CString str;
if (! str.LoadString( IDS_STRING1 ))
{
AfxMessageBox("Error Loading String: IDS_STRING1");
...
}
|
|
|
|