|
do not name your class CDatabase, because CDatabase is a MFC-class and it's the best way to connect to database through CDatabase.
then you create CRecordset-derived class and pass a pointer to database as a parameter.
ExecuteSQL(...) is a method of MFC CDatabase class.
class CMyApp: public CWinApp {
CDatabase m_db;
};
BOOL CMyApp::InitInstance()
{
m_db.Open(...);
}
void CMyView::Func1() // or something else
{
CMySet set(&theApp.m_db);
set.Open(...);
// etc...
}
Dmitry Timin
|
|
|
|
|
I've created a project, mfc.exe type, that will link in several static libraries located in the same workspace. Each library will be a CWinthread derived class that could be the home for a dialog box and its controls. The controls I would like to update from any of the other threads.
I have been able to get a dialog box to appear from a thread class but have not been able to get a control to update like static text.
Here's kind of the flow:
main
{
afxbeginthread (lcd, ...)
lcd->startup
lcd->display(string)
...
}
lcd::startup
{
Startup dlg
dlg.DoModal
...
}
lcd::display(string)
{
dlg.display(string)
...
}
CStartup::display(string)
{
SetDlgItemText (IDC_TEXT1, string)
...
}
If you know of a link to a page with info about what I described or have a comment, it would be appreciated.
Thanks,
Clay
|
|
|
|
|
main
{
afxbeginthread (lcd, ...)
lcd->startup
lcd->display(string)
...
} The problem lies in the bolded line. Executing lcd::startup from the main thread does not cause the thread to actually execute this function --it is th main thread that executes it instead. So, you're creting a thread and then launching a modal dialog box in the context of the main thread. No wonder, the app won't reach the next line (intended to change the static text) until the dialog has closed!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
>Each library will be a CWinthread derived class that could be >the home for a dialog box and its controls. The controls I >would like to update from any of the other threads.
Try using the PostThreadMessage function of your CWinThread-derived class. Your class should have a message handler for the message (lookup: ON_THREAD_MESSAGE )
Bijesh
--------------------------------------------------
|
|
|
|
|
I need a folder / file search dialog - I am aware of CFileDialog, but this won't return folder paths, only file paths. Is there any other class which will give me this combined function ? (The folder search is often used in installation programs, so I guess something standard must exist)
Doug
Doug
|
|
|
|
|
Check SHBrowseForFolder out.
Oops. This will only work for selecting folders, not both folders and files.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for pointing out SHBRowseForFolder(). (As a last resort, I can use both CFileDialog AND SHBroweForFolder() ) However, I'm currently trying to compile the following:
BROWSEINFO bi;
:SHBrowseForFolder(&bi);
I have included ShellApi.h but am getting C2065 on BROWSEINFO. (I originally found BROWSEINFO declared in shlobj.h and thought that ShellApi.h would fix the problem but it doesn't !
Where am I going wrong ?
Doug
|
|
|
|
|
I am inexperienced with Spy++, and I have searched the MSDN site and read and re-read the Help Docs that come with Visual C++, and, I cannot get the the message log to save to a log file. I suspect that I am doing something incredibly dumb, something that would be obvious to some of you more experienced coders. Also, when operating Spy++, I get what appear to be spurious messages (I have the Introductory Edition, so maybe this normal). Anyway,...
I launch Spy++, click on windows (from the menu) and select a window, then select messages, at which point I get a popup message box telling me that some other process is logging the messages in that window. If I move the cursor into the selected window, the log starts and I get a rapid-fire list of cursor and hit test messages (these are actually the correct mesasages). Then I select Options and the Output tab I check the save log to file (or something like that), and provide a path, and check OK. The file always shows up at the location specified but empty, and sometimes I get an invalid log file message (and sometimes I don't). I searched for information on what a valid file type would be and came up with nada. I am typing in a typical pathname, like "C:\Folder Name\File Name.ext" (without the quotes). Would this be a log or text file, or does it even matter?
Do any of you people use this feature? If so, how does it work? I would appreciate any useful information. Thanks.
|
|
|
|
|
Try start spying on a window. Press F8 (Stop Logging). Then go to options and fill in a filename. The Start Logging again. That's the only way I got it to work.
|
|
|
|
|
Mike Nordell,
You know, I did accidentally get it to work one time, and I couldn't figure out what I had done. I'll bet that was it, because I did start and stop the logging several times trying to determine what was what. Thanks for that clue, I was ready to kill (an innocent bystander) in frustration.
It didn't seem intuitive or even logical, that it should be necessary to stop and then start spying again,...and you would think they could include that in their Help.
|
|
|
|
|
I have moved my project around as it needs to run on several machines. It works fine, but I have one problem that is a bit annyoing.
When I modify a file the updates aren't recongnized right away and when they are recongnized I get a message stating that the file was modified outside the project. How can I fix this? I was thinking just deleted the project and build a new one?
Any ideas?
|
|
|
|
|
Check the clocks of the machines. Most likely some of them are delayed by a significant amount of time (or the original one has somehow been boosted into the future).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Doesn't seem to be the problem. Weird thing is it doesn't happen with all the files. Hmm?
|
|
|
|
|
Next thing to do is check the offending files' last modified date (it smells horribly like a date problem ).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm going to try and set the dates on all the files and I'll let you know.
Thanks for the help,
Jim
|
|
|
|
|
I am developing the Print Preview for my application and I want to have certain portions of the text writeen in Bold letters . I use the pDC Object of the OnPrint function . Please help
|
|
|
|
|
Something like this:
HFONT hFont=(HFONT)GetCurrentObject(*pDC,OBJ_FONT);
ASSERT(hFont);
LOGFONT LF;
VERIFY(CFont::FromHandle(hFont)->GetLogFont(&LF));
LF.lfWeight=FW_BOLD;
CFont BoldFont;
VERIFY(BoldFont.CreateFontIndirect(&LF));
CFont* pOldFont=pDC->SelectFont(&BoldFont);
pDC->SelectObject(pOldFont);
BoldFont.DeleteObject();
|
|
|
|
|
i do not Find a Method as SelectFont and is not listed in the Class member Listing for CDC ?
|
|
|
|
|
Sorry, yeah.. I was typing in anew... you gotta debug it.
That should be SelectObject.
|
|
|
|
|
Some code like this will work (I think):
OnPrint(...)
{
...
if(portion in bold){
LOGFONT lf;
pDC->GetCurrentFont()->GetLogFont(&lf);
lf.lfWeight=FW_BOLD;
CFont font;
font.CreateFontIndirect(&lf);
CFont * pFontOld=pDC->SelectObject(&font);
pDC->SelectObject(pFontOld);
}
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the help. I find that the Text Gets Shrunk rather than Get Bold ?
|
|
|
|
|
??? Sure you're changing the weight and not the width? Don't know, try playing with the various params of LOGFONT .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Here's the situation:
I have a program that runs in the system tray, and I want to be able to open a Dialog that sits on top and has focus over all programs currently running (kind of like a system message from Windows). Since DoModal does not accomplish this, is there something else I can do? Thanks.
Todd
|
|
|
|
|
One solution is to override the event handler for ON_KILLFOCUS. Call SetFocus().
Kuphryn
|
|
|
|
|
Did you really mean the focus? (where keyboard input is sent)
Or are you looking to make the window topmost, activated and
prevent activation of other windows until yours is dismissed?
(handling WM_ACTIVATEAPP and using AttachThreadInput and
SetForegroundWindow to reassume the foreground if the user
tries to switch to another window. ick )
|
|
|
|