|
Ryan Binns wrote: AFAIK, PJ's framework doesn't actually use MFC.
Are classes such as CWinApp , CString , CSingleLock , and CStringArray no longer considered part of MFC?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Damn. Missed the header file
Yes you're right, however CWinApp is not used in the library - only in the example. The only MFC classes he uses are non-windowing related (CString, CTime, CStringArray, CCriticalSection, CByteArray)
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
I've writen a Service with this Framework and Im alsoo using MFC
(since it was a port from a MFC SDI application) and don't have a problem with it.
I did however set the service to interact with the desktop.
Maybe you can set this option to see what happens.
Otherwise it could be some other error causes this problem.
In that case could you post the code where you think that the service hangs.
codito ergo sum
|
|
|
|
|
Ok guys,
I did it with the MFC classes and it´s ok. I used de CFileFind from MFC with a service created with the
"SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS" options.
The service is running with a timer inside. I´ve only noticed that you have to be very very aware of all memory leaks. You can get those 122 erros ("The data area passed to a system call is too small.").
Now I´m trying to use an ADO class from
href="http://www.codeguru.com/cpp/data/mfc_database/ado/article.php/c6729/"
but I´m getting more erros, but that is, maybe, for using ::CoInitialize in a Multi-thread application.
Thank you all. I´ve appreciated this discution.
|
|
|
|
|
I have owner drawn control using XP themes. Does anybody know whether is it better/recommended to call OpenThemeData() on creation of control and keep the handle for life of the object (or until theme is changed) or open then close it every time when painting occur ?
Thank you!
rrrado
|
|
|
|
|
I open it when I create the control and keep it for the life of the object. I've no idea if that's the correct way to do it or not, I just do it as I want my painting code to do as little as possible - so I don't do things like Open() there.
Check this[^] out, it makes things pretty easy when you're working with styles.
- Dy
|
|
|
|
|
I'm using another themes wrapper found here on codeproject (CThemeUtil).
I'm asking because I don't know whether it is more expensive to open theme data every time or maybe block some resources and memory by opened handle to theme for longer time than neccessary.
I've seen some XP controls opening theme data every time (for example CXPStyleButtonST).
So I'm also doing this and I haven't notice some slow drawing but haven't tried this on slower computer
rrrado
|
|
|
|
|
You can open a theme handle and keep it open. You'd only need to close/reopen it if your app gets a WM_THEMECHANGED message. Check out CThemeImpl in WTL for more details.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi
I have two applications - one written in c (dos window), the other in VC++, which need to communicate a variable value to each other. I currently do this by writing the value into a file from one application, and then reading it back in the other application.
This all works, but I was wondering whether there is a more elegant way of doing this?
Anyone help?
Thanks
Mike
|
|
|
|
|
There are several forms of Interprocess Communication (IPC). For example: clipboard, DDE, WM_COPYDATA , pipes, sockets, RPC.
What you have will probably work as long as you don't encounter the reader/writer problem.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Thanks for your help
What I have done is writen the data into a tempory file, and then renamed it to the actual file name that is required - this does appear to get over any file sharing problems that may have been encountered, and does work.
The old C program that I have is written using Quick C, and (as far as I know) is unable to respond to Windows Messages, or use the clipboard, sockets, etc.
In the VC app, I have set up a timer, which checks every 500mS (this is fast enough) to see if the file is there - if it is, it reads in the data. I am happy with the way the apps work at the moment, I just wanted to use a neater method of doing this, if possible.
Mike
|
|
|
|
|
You might want to look into the ReadDirectoryChanges function for your 32-bit application, so your timer does not have to exist. Your program will be 'signaled' when the file appears in the folder, assuming you totally control access to the folder itself - meaning, do not choose a common folder that gets a lot of activity, or your program will be notified for every file change.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
But be careful if you are looking for changes on remote (network) shares. Both ReadDirectoryChangesW(...) and FindFirstChangeNotification(...) may experience problems when working with network shares - regarding path lengths and/or the remote system might not support notification of filesystem changes in such a manner. (Experienced this myself more than one time.)
IOW, if your application could be working with remote filesystems, it should have a polling interval as a fallback as well. Nothing worse than getting a call first thing in the morning from a site saying that your "real-time file processing application" stopped working this morning (they upgraded a *nix box that hosted one of the shares used the previous evening, and its network file support was slightly broken).
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Is it possible to start a class member function as a separate worker thread or do I have to define the typical UINT MyThread(void* pParam) type of function?
If I do need to define the typical thread function, how can I encapsulate every thing into a class?
Thanks in advance!
|
|
|
|
|
Cteate static MyThread function in your class:
<br />
UINT CMyClass::MyThread(LPVOID param)<br />
{<br />
CMyClass* _this = (CMyClass*)param;<br />
<br />
return _this->DoSomeWork();<br />
<br />
}<br />
You can start thread this way AfxBeginThread(MyThread,this);
rrrado
|
|
|
|
|
Don't forget that the 'thread function' has to be a 'static' function.
Something like this...
class CMyClass
{
public:
BOOL StartThread() { m_pMyThread = AfxBeginThread( MyThreadFn, this ); }
protected:
CWinThread* m_pMyThread;
UINT MyThreadFn();
static UINT MyThreadFn( LPVOID pThis ) { return ((CMyClass*)pThis)->MyThreadFn(); }
};
This[^] is the best article in my opinion to get started with multithreading.
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
Thanks Roger.. I wil try that...
|
|
|
|
|
I tried your solution and everything compiles and runs but my thread has no access to the class member variables. I initialize them in my class constructor but the thread function sees them as uninitialized.
Is there a way for my thread to access class member variables and functions.
Thanks!
|
|
|
|
|
You cant access nonstatic member from static function directly.
To solve this issue, create a static pointer to same class like
static CYourClass *thisClass; and assign this pointer to the static pointer, then user thisClass pointer in your thread. and aceess variable & functions using thisClass->fun() or thisCLass->varibel
|
|
|
|
|
I am not sure I completely understand your solution. Can you explain it a bit further?
Thanks.
|
|
|
|
|
I tried what you suggested and I got the following error:
CTCPServer::ListenThread': function call missing argument list; use '&CTCPServer::ListenThread' to create a pointer to member
Is there anyway to resolve this? If you need to see the code please let me know.. I didn't want to post it unnecessarily.
Thanks for your help.
|
|
|
|
|
The scenario is this:
In a 16 bit application A.app I am calling a 32 bit dll B.dll with a method exposed "DisplayDialog(HWND hWnd)".
DisplayDialog is called through the following sequence:
hDD = LoadLibraryEx32W(B.dll);
hDisplayDialog = (DISPLAYPPROC)GetProcAddress32W(hDD, "DisplayDialog");
CallProcEx32W(1, 1, hDisplayDialog, hWnd);
The resource for the dialog which I want to diaplay is in a 2nd 32 bit dll
C.dll. I am loading C.dll in B.dll using
hInstance = LoadLibrary(C.dll).
Then to display the dialog I am using this code in B.dll:
hDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_SOME_DIALOG), hWnd, (DLGPROC)SomeDlgProc, NULL);
ShowWindow(hDlg , SW_SHOWNORMAL);
SomeDlgProc is defined in B.dll.
hDlg is comming out as NULL.
GetLastError following the function call is returning 0.
Please advice what is going wrong.
Regards,
The scenario is this:
In a 16 bit application A.app I am calling a 32 bit dll B.dll with a method exposed "DisplayDialog(HWND hWnd)".
DisplayDialog is called through the following sequence:
hDD = LoadLibraryEx32W(B.dll);
hDisplayDialog = (DISPLAYPPROC)GetProcAddress32W(hDD, "DisplayDialog");
CallProcEx32W(1, 1, hDisplayDialog, hWnd);
The resource for the dialog which I want to diaplay is in a 2nd 32 bit dll
C.dll. I am loading C.dll in B.dll using
hInstance = LoadLibrary(C.dll).
Then to display the dialog I am using this code in B.dll:
hDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_SOME_DIALOG), hWnd, (DLGPROC)SomeDlgProc, NULL);
ShowWindow(hDlg , SW_SHOWNORMAL);
SomeDlgProc is defined in B.dll.
hDlg is comming out as NULL.
GetLastError following the function call is returning 0.
Please advice what is going wrong.
Regards,
|
|
|
|
|
Background
my MFC application developed on VS7.1, wrapped in InstallShield.
Users with Win2000 cannot run new project element.
(also installed SP4, .NetFramework and sometimes VS6)
Users with XP - no problems
Users with Win2000 and VS7 - no problem.
InstallShield delivers Mfc71.dll, mfc71u.dll, msvcp71.dll, msvcr71.dll, msvcrt.dll
New element is some windows hooking code.
I cannot use debug on VS7 becuase this fixes the problem.
I've tried Installshield dynamic scanning but i couldn't see what was missing.
The hooking code only includes stdafx.
Whats the easiest way to find the problem without adding loads of Message Boxes? I'm just toooo lazy for that
JBW
You can please some of the people all of the time and all of the people some of the time but not all of the people all of the time.
|
|
|
|
|
Use Process Explorer from SysInternals to see what modules are loaded while your program is running. One of those is probably missing from Windows 2000. Otherwise, perhaps you used an API that does not exist on Windows 2000.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Process explorer did show that for some reason Kernel32.dll is missing from my apps runtime on the problem machine. I don't get any system messages to warn me of an error though. I've tried statically linking my kernel32.lib but that doesn't work. It feels like some dll versioning problem but I don't really know so I'll have to keep looking.
You can please some of the people all of the time and all of the people some of the time but not all of the people all of the time.
|
|
|
|