|
|
Mike,
I am developing on Win2k and have the Platform SDKs installed. I have included c:\Program Files\Microsoft SDK\include and c:\Program Files\Microsoft SDK\lib (to get uxtheme.lib). However, when the compile finishes, I get an error dialog that says "Uxtheme.dll" cannot be found. Doesn't this mean I have to have Uxtheme.dll installed on Win2K? BTW, my application works nice on XP, but I have to make it work on Win2k and NT as well.
Thanks for all of your help!
Bob
|
|
|
|
|
uxtheme.dll isn't present on 2K (or earlier). You can't link with uxtheme.lib since, as you've seen, that makes the app require that DLL to load.
You have two choices:
1. use the /delayload:uxtheme.dll linker switch
2. use LoadLibrary/GetProcAddress at runtime
Either way, you must add OS checks to your code so that you don't call the functions in uxtheme unless the app is running on XP or later.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
If my rhyme was a drug, I'd sell it by the gram.
|
|
|
|
|
I've used C++ 6's built-in macro to print all open files, only to end up having it try to print out the whole mfc. I wanted to know is there any freeware C++ source code printing programs out there that also format the code in a nice-looking way.
thanks
bdiamond
If it's broken, I probably did it
|
|
|
|
|
bdiamond wrote:
only to end up having it try to print out the whole mfc
How did you do that? That has never happened to me. It should only print the files that you have currently open in devstudio...
John
|
|
|
|
|
I know that it SHOULD do that, but it only seems to do it right for me once out of ten times. any other time I seem to have to deal with a few hundred pages of MFC source code. I've been using textpad lately, but I have to go and open them all up from TextPad, then print them.
If it's broken, I probably did it
|
|
|
|
|
Are you sure that these MFC files were not open in developer studio when you hit print? The macro that prints is a very simple macro that gets a list of the open documents and prints each one.
Here is the code for the macro:
Sub PrintAllOpenDocuments ()
'DESCRIPTION: Prints all open, active documents.
'Small, quick macro, but it can be usefull.
for each doc in Application.Documents
Doc.PrintOut
next
End Sub
Unless devstudio somehow thinks more files are open than you actually have open I do not see how this can fail...
John
|
|
|
|
|
I also thought about that and that may be the case (developer studio thinking I have more files open that I actually do). But since then I've gotten a new machine and reloaded it. I haven't tried that way in so long now because of the problems I was experiencing before, but I still wanna find a way with better formatting capabilities if possible.
If it's broken, I probably did it
|
|
|
|
|
I have used source code printer applications in the past but since my projects are now way too big to print I just print a few pages at a time using developer studio. I have one link to a couple of printer programs but I do not remember the one that I used in the past. I may still have a copy on my hd though... Here is the one link: http://www.softpanorama.org/Tools/beautifiers.shtml#C++[^]
John
|
|
|
|
|
|
If I create a multi threaded application how do I pass data from my main thread to my spawned thread.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Messaging will be the best bet i guess, create a user defined message and use postthreadmessage api to post the message and appropriate data along with it.
|
|
|
|
|
Quick question. Is there a limit to the amount of data that can be passed? Or could I pass a char pointer to the spawned thread that have it look there for the data?
Thanks
PS I know this is a totally different subject but if I created a variable like CString holdBuf is this a char pointer or is char holdbuf[] a char pointer. I'm not sure how I would say that I want to pass a pointer to CString holdBuf.
Thanks again
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Passing strings from threads to the main app can get tricky esp if your thread exits before all the data can be passed etc. A few months back I found a really good article here on codeproject on the subject.. I believe the classes are called CMessageString and CMessageStringManager. You should look into using the classes or at least read the article it will give you some great info. (sorry I dont have the direct link to the article)
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Tom Wright wrote:
PS I know this is a totally different subject but if I created a variable like CString holdBuf is this a char pointer or is char holdbuf[] a char pointer. I'm not sure how I would say that I want to pass a pointer to CString holdBuf .
CString has a operator(LPCTSTR) that is able to transparently cast the CString into a Long-Pointer-to-Constant-T_STRing, which is what LPCTSTR means. In non-unicode environments this is indeed a const char* .
When you need a non-const char*, you have to use CStrings GetBuffer()-function (and don't forget to call ReleaseBuffer() after use!), which gives you a char*.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
jhwurmbach wrote:
CString has a operator(LPCTSTR) that is able to transparently cast the CString into a Long-Pointer-to-Constant-T_STRing, which is what LPCTSTR means. In non-unicode environments this is indeed a const char*.
When you need a non-const char*, you have to use CStrings GetBuffer()-function (and don't forget to call ReleaseBuffer() after use!), which gives you a char*.
So is const char* the same as say (outloud) "constant char pointer" which is the same as CString?
And why would one want a const char* ?
Tom
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
So is const char* the same as say (outloud) "constant char pointer" which is the same as CString? /i>
No. const char* and CString is not the same. But if you politely ask the CString , it will behave like a const char* would.
Tom Wright wrote:
And why would one want a const char* ?
For display? For printing? For anything that need not modify the string.
And that is about 90% of all string uses.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hi,
When I try to add new records for my database application, whatever words/numbers I entered into the edit control, got disappeared. I found that it is due to the clock timer in my dialog. I don't know why. When I masked off the clock timer portion, I can add new records.
How do I add in new records even with the clock timer ON.
Best Regards,
Siew Hoon
|
|
|
|
|
Dear sirs !
I ask you kindly to help me with my problem. I want to understand the reason of the problem I see. I use VC++ 6.0 with SP 5, OS Windows 2000 Professional.
I create two MFC Extension DLLs. The first of them exports class CMyClassA. The other one exports CMyClassB. Each of the classes uses it’s own resources, for example Dialogs.
CMyClassA::ShowDialog() method shows a DialogA.
CMyClassB::ShowDialog() method shows a DialogB.
Next step.
I want to import these 2 classes from DLLs to my new Project, let it be SDI-application. I create it using MFC AppWizard(exe). I link *.lib files to the project.
When I import ONLY CMyClassA, or ONLY CMyClassB, everything is fine, everything works perfectly as I need. As soon as I import both CMyClassA and CMyClassB to the same application, problems are coming. These two classes begin to conflict by their resources. So I can’t call methods ShowDialog() for any of them. Instead of result I see something like this: “An unsupported operation was attempted”.
What’s wrong with these DLLs can be ? How to solve the problem of resources conflict between DLLs ?
I would be very grateful for your help.
Best regards, Alexander.
|
|
|
|
|
Try this:
In the function in your DLL that invokes the dialog add the following code:
// Get the Handle to the DLL
HMODULE hDLL = GetModuleHandle("MyDLLName.dll");
// Get the current resource Handle (i.e.from whomever
// called us -- probaby for the .exe)
HINSTANCE hEXE = AfxGetResourceHandle();
// Set the current resource Handle to point to the DLL's resources
AfxSetResourceHandle((HINSTANCE) hDLL);
// Now create & show the dialog -- it will use the DLL's resources
CMyDialog Dlg;
if (Dlg.DoModal() == IDOK) {
...
}
// Restore the resource handle to where it was when we were called
AfxSetResourceHandle(hEXE);
// Now it is safe to return
return;
John
|
|
|
|
|
Dear John,
Thank you for your advice, but the first try didn't get the result expected.
But idea is very interesting for me by itself.
I'll try again, may be I just have to pay attention to any other factors too.
|
|
|
|
|
Do you have a common resource.h file so that none of the resource IDs will confilct?
John
|
|
|
|
|
Dear John,
Thank you very much for your help, finally your first answer was exactly what I needed. I understood it today after I repeated my tests carefully and accurately.
You can’t imagine how happy now I’m ! This problem with resources worried me during almost a month. It was growing together with number of my DLLs. Now I use 11 different DLLs in the same project. And finally you helped me to find such a simple and perfect decision !
I’m very grateful to you !
With best regards and wishes from Russia.
Alexander.
|
|
|
|
|
You are welcome. This was code I got on another website. I generally do this a little bit differently but if you understand the example I gave you, you can understand what I do.
Here is what I do with all my DLLs (this was done with an vc6 appwizard that I created for that purpose):
In the file that has DLL main
#include "stdafx.h"
#include <afxdllx.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static AFX_EXTENSION_MODULE ExtDllTestDLL = { NULL, NULL };
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
UNREFERENCED_PARAMETER(lpReserved);
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("EXTDLLTEST.DLL Initializing!\n");
if (!AfxInitExtensionModule(ExtDllTestDLL, hInstance))
return 0;
new CDynLinkLibrary(ExtDllTestDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("EXTDLLTEST.DLL Terminating!\n");
AfxTermExtensionModule(ExtDllTestDLL);
}
return 1;
}
EXTDLLTEST_DLLState::EXTDLLTEST_DLLState()
{
m_hInstOld = AfxGetResourceHandle();
AfxSetResourceHandle(ExtDllTestDLL.hModule);
}
EXTDLLTEST_DLLState::~EXTDLLTEST_DLLState()
{
AfxSetResourceHandle(m_hInstOld);
}
Then in your dll header file:
#if defined(EXTDLLTEST_STATIC)
#define EXTDLLTEST_CLASS_EXPORT
#elif !defined(EXTDLLTEST_DLL)
#define EXTDLLTEST_CLASS_EXPORT AFX_CLASS_IMPORT
#else
#define EXTDLLTEST_CLASS_EXPORT AFX_CLASS_EXPORT
#endif
class EXTDLLTEST_CLASS_EXPORT EXTDLLTEST_DLLState
{
public:
EXTDLLTEST_DLLState();
~EXTDLLTEST_DLLState();
protected:
HINSTANCE m_hInstOld;
};
Then to use it is very simple. In a function that I need resources from this dll I declare a variable of EXTDLLTEST_DLLState and all the work is done for me:
int CFileDlg::DoModal()
{
EXTDLLTEST_DLLState state;
return CDialog::DoModal();
}
Notes:
I export all symbols from my dlls by putting a EXTDLLTEST_CLASS_EXPORT before the symbol name like EXTDLLTEST_DLLState above. EXTDLLTEST_DLL is only defined in the project that contains the dll. If you do not want to export EXTDLLTEST_DLLState you can do it completly transparent to the end user. This is what I typically do. You can do this with dialogs by overriding DoModal and Create (if you want to support modeless dialogs).
John
|
|
|
|
|
How to move CDailog child window under other it's child window?
I need to show one child window on toop of others.
Problem:
Or for owner-drawn window was not drawing
background above toher controls.
How to do that?
thanks.
|
|
|
|