|
I was afraid that was the case. Thanks anyway Rob.
I was expecting there to be a CMFCDialogWithBellsOn or something, but apparently not.
The thing I don't really understand is that you can create a dialog app with the Office 2007 styles, or you can create an MDI app with the Office 2007 styles, but if you launch a dialog box from that MDI app then it appears to use the standard OS style. Obviously the documentation is more than a little sparse and despite a great deal of time searching I've had no joy.
|
|
|
|
|
If a dialog app works, then there must be a way to do this - I am at home now, so can't check, but I'll look into it tomorrow.
I was a big fan of this stuff when it was BCG, so have spent a lot of time working with the MFC Feature Pack.
|
|
|
|
|
Hello,
Is there a function to get the number of rows in a ListCtrl? I have to edit all items and found
listCtrl.GetHeaderCtrl()->GetItemCount();
to get the number of columns. But how can I get the number of rows. Something like 'while(listCtrl.GetNextItem...' doesn't work - it seems, that it's an endless-loop.
Thanks, GE
|
|
|
|
|
CListCtrl::GetItemCount();
so you can write : listCtrl.GetItemCount();
Retrieves the number of items in a list view control.
Gerhard-E wrote: listCtrl.GetHeaderCtrl()->GetItemCount();
you are calling it on the header control that is why you get the number of columns
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Seems to work perfect.
Very many thanks for the fast answer, GE
|
|
|
|
|
Before a button event, I am posting a message to MainFram to display a popup with a progress bar, pop is displayed, but the progress in not updated on the dialog. Please advice
void CMainFrame::OnTimer(UINT nIDEvent)
{
if (iStopProgress!=1) // This working fine
{
// update progress..
iPrgCounter++;
PostMessage(WM_USER_THREAD_UPDATE_PROGRESS, iPrgCounter, nMaxPrgValue);
Sleep(100);
DoEvents1();
}
else
{
popupDlg->OnCancel();
DoEvents1();
Sleep(100);
}
CMDIFrameWnd::OnTimer(nIDEvent);
}
void CMainFrame::OnStartPrgBar()
{
popupDlg= new CPrgpopup();
popupDlg->DoModal();
}
void CMainFrame::OnStopPrgBar()
{
iStopProgress=1;
if (KillTimer (Timeval)!=TRUE)
{
AfxMessageBox("Timmer Kill Failed");
}
else
{
AfxMessageBox("Timmer KILLED");
popupDlg->OnCancel();
AfxMessageBox("MF Stop");
}
}
UINT CMainFrame::StartProgressBarThread (LPVOID param)
{
THREADSTRUCT* ts = (THREADSTRUCT*)param;
if (ts->_this->popupDlg->DoModal()==TRUE)
{
hwnd=ts->_this->popupDlg->GetSafeHwnd();
ts->_this->popupDlg->m_ProgressCtrl.SetRange (0, nMaxPrgValue);
}
return 1;
}
void CMainFrame::OnUpdatePrgBar()
{
popupDlg->m_ProgressCtrl.StepIt(); // Not getting update on Dlg
DoEvents1();
Sleep(100);
}
|
|
|
|
|
ptr_Electron wrote: DoEvents1();
SHAME ON YOU!
because you're recalling the Worst of the Weird Visual Basic Statements
BTW You've done already many posts: Did you ever notice the code block button?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
A much simpler design: Do your background work on worker threads
and leave all your UI stuff on ONE UI thread.
Your code is more complicated than it needs to be!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
After posting message to MainFrame, a thread is started to display popup progressbar, and a timmer keep updating the prg bar(not happning), once stop getting stop messge posted from dialog timmer is killed, and popup is closed. every thing is fine except the updating the progress bar.
void CMainFrame::OnTimer(UINT nIDEvent)
{
if (iStopProgress!=1)
{
iPrgCounter++;
PostMessage(WM_USER_THREAD_UPDATE_PROGRESS, iPrgCounter, nMaxPrgValue);
Sleep(100);
DoEvents1();
}
else
{
popupDlg->OnCancel();
DoEvents1();
Sleep(100);
}
CMDIFrameWnd::OnTimer(nIDEvent);
}
void CMainFrame::OnStartPrgBar()
{
popupDlg= new CPrgpopup();
popupDlg->DoModal();
}
void CMainFrame::OnStopPrgBar()
{
iStopProgress=1;
if (KillTimer (Timeval)!=TRUE)
{
AfxMessageBox("Timmer Kill Failed");
}
else
{
AfxMessageBox("Timmer KILLED");
popupDlg->OnCancel();
AfxMessageBox("MF Stop");
}
}
UINT CMainFrame::StartProgressBarThread (LPVOID param)
{
THREADSTRUCT* ts = (THREADSTRUCT*)param;
if (ts->_this->popupDlg->DoModal()==TRUE)
{
hwnd=ts->_this->popupDlg->GetSafeHwnd();
ts->_this->popupDlg->m_ProgressCtrl.SetRange (0, nMaxPrgValue);
}
return 1;
}
void CMainFrame::OnUpdatePrgBar()
{
popupDlg->m_ProgressCtrl.StepIt();
DoEvents1();
}
|
|
|
|
|
Why is there a DoModal call in two places?
You do know DoModal doesn't return until the dialog
is dismissed right?
You also can only call methods on MFC window objects on the same thread
the window was created on.
Again, your design is unnecessarily complex. Just create a modeless progress
dialog on the UI thread, fire off your worker thread, and let the worker thread
post messages to the modeless dialog to update the progress bar.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I'm having a problem with my MFC program. It's an MS outlook style splitter window application. In one of it's CFormViews, I want the user to be able to open a dialog that relates to the currently selected row of a report style List, when they press return, just like MS outlook. If the user interacts with the view, this virtual function is called:
BOOL CMyFormView::PreTranslateMessage(MSG* pMsg)
{
if(GetFocus() != &ReportCtrl)
return CFormView::PreTranslateMessage(pMsg);
if (pMsg->wParam == VK_RETURN )
{
PostMessageA(ID_OPEN_RECORD,0,0);
return TRUE;
}
return CFormView::PreTranslateMessage(pMsg);
}
When this dialog is closed, I highlight ReportCtrl in this manner:
...
MyDialog.DoModal();
ReportCtrl.SetFocus();
....
Unfortunately, this has an odd effect; When I press return in the child dialog, the dialog's default button, OK, is pressed, but then "the enter" somehow propogates down to CMyFormView, causing the dialog to immediately respawn - That's obviously not desirable. What should I do? How can I make the Right pane/ CFormView get back focus without this happening?
For some reason, directly calling the function mapped to the ID_OPEN_RECORD Message, or Sending rather than posting a message, causes assertion failures. I didn't make the ID_OPEN_RECORD especially to solve this problem though - It was originally created so that the user could press an "open record" button on the toolbar, and have that work in every view.
Regards,
Sternocera
|
|
|
|
|
Hi all!
I'am working on an application, that connects to a mysqlhost
in the internet. for this i used the mysql c api and the libmysql.dll
in a mfc application project.
This works fine but no i want to compile an application, that does
not need the libmysql.dll.
Is there any possibility to connect to a mysqlserver without libmysql.dll?
Or can i merge the libmysql.dll into my application, so that i only have one
working exe file?
Thanks in advance!
|
|
|
|
|
Why do you want to compile an application that does not need libmysql.dll?
|
|
|
|
|
Hi,
at work i have to deploy a stand alone exe application, that has
no dependency to any libraries, that are non standard on windows
platforms. also, because the programm is used commercial, we are
not allowed to supply our programm with libmysql.dll to custommers.
thats the reason, because i have to work without libmysql.dll.
|
|
|
|
|
You can't. No matter what RDMS you use, there's going to be some
required dependency, even using ODBC/ADO/etc.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm a little curious as to why not.
I mean, you can use something like Thinstall or MoleBox or PBundle or AlloyFiles to package a whole bunch of files into a single .exe file.
You can use FileMon to get a list of all the file transactions made by an app, allowing you to ensure that you don't inadvertantly miss a file, as FileMon will list all files that have an open,read or write operation performed.
I've got a single .exe file that contains all of Office 2007 on my flash drive. I've also got single-exe-file versions of 3dsMax, Maya & ZBrush. Surely a simple DB program would be a snap comapared to these?
simon
|
|
|
|
|
Linking to a library and packaging files into single executables
are two different things.
To avoid the separate DLL, you need to be able to statically link to the
LibMySQL libraries. Can you build a static library from the libmysql sources?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Linking to a library and packaging files into single executables
are two different things.
Yup, sure are. If you link to a static lib, then a flaw is discovered you're in the unenviable position of having to roll-out a replacement exe file. It also means that your app may consist of many files.
If on the other hand, you package the DLL-using app with Thinstall for example, if a flaw is discovered in the bundled DLL file, you can just drop the updated DLL file into the application's sandbox folder and the app will use the new DLL rather than the packaged one. So, you still get the best of both worlds with Thinstall. You also get the advantage of a single compressed file, which alone is a good enough reason to package something if it will be used on a usb drive or via a network.
Mark Salsbery wrote: Can you build a static library from the libmysql sources?
Yeah, course you can build either a static or a dynamic version of a mySQL app. You've just gotta link with mysqlclient.lib rather than libmysql.lib, which simply loads libmysql.dll on demand.
|
|
|
|
|
Apparently I missed the entire point of your question
I thought you wanted to eliminate shipping libmysql.dll with your app.
The only way to do that is statically link to a static library version
of that DLL.
Sorry!
Mark
*edit* well shoot - you aren't even the OP LOL I'm not sure what you're getting at...<br />
as I understand it, the OP is NOT allowed to ship the DLL.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi All,
I am working on one application where i use an edit control and on button click i just want to delete the text of edit box using VK_BACK.
my code is
HWND hWnd = NULL;
hWnd = ::GetDlgItem(m_hWnd, IDC_EDIT);
::SendMessage(hWnd, WM_KEYDOWN, (WPARAM)0, (LPARAM)VK_BACK);
Thanks in advance.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
modified on Wednesday, July 30, 2008 8:28 AM
|
|
|
|
|
Perhaps the Edit control is coded to respond to WM_KEYUP rather than WM_KEYDOWN, or maybe these are ignored in favour of WM_CHAR. It's possible, although unlikely, that you might need to send all 3 in the right order. If none of that works you'll need to do a GetText and something to get the cursor position, remove a character yourself and do a SetText to put the modified text back.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Is using VK_BACK a constraint?
Shilpi Boosar wrote: button click i just want to delete the text of edit box "
Since you want to delete the text in the edit box why don't you simply use SetWindowText(/*windowhandle*/,"").
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
No because my main concern is to delete the text of edit box using VK_BACK when i click the button.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
This should work then.
::SendMessage (hwndEdit,WM_CHAR,(WPARAM)VK_BACK,(LPARAM)1);
Rate it if this helps
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks It Works
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|