|
Problem:
Main app using 3rd party libraries as base for most
classes. These 3rd party libs include windows.h.
Have DLL with descendant of CDialog in it. I'm told (MSDN) you can use a statically or dynamically linked Win32 DLL using MFC within a non-MFC program (the main program doesn't see the MFC).
How?
When I include the header for a class in my DLL (which at the moment contains nothing, was planned to contain my CDIalog), the main project won't build because it complains about including stdafx.h (I have afxwin.h included therein). If I try to leave out stdafx.h, of course the DLL itself won't build.
So what do I need to do to create a header that can be included in my main project, has the exports that won't drag MFC into the main App, and so that the DLL will still build?
Any help appreciated.
|
|
|
|
|
You can't export an MFC class from a DLL to a non-MFC application. There are many reasons for this, but suffice it to say that it can't be done.
What the MSDN means when it says you can use MFC in a DLL and call it from a non-MFC app, was that you can have a DLL that exports various functions, which can in and of themselves call MFC. You cannot call MFC derived classes directly from your app.
So, what you would do is create an export called "ShowMyDlg()" which will create the CDialog, and another function called "GetDataFromMyDialog()" to retive the data from it.
|
|
|
|
|
Howdy!
I assigned the OFN_ALLOWMULTISELECT flag when I created my Open file dialog, but I don't know how to get the selected filenames.
Oh btw, I'm not using MFC.
Anyway, if you can help me, please post a reply.
Thanks!!
|
|
|
|
|
The lpstrFile member of your OPENFILENAME struct points to a double-null-terminated list of the files. For example:
c:\foo\bar.exe\0c:\foo\bleat.exe\0\0
|
|
|
|
|
Hello,
I have a function that returns several strings. This function is run over and over again many times. I would like to store all the returned strings in an array. I'm assuming that I have to use a struct. But, how do I get the values inside by index after its created. In VB (yea, i know.) It would be something like this:
Private Type StrData
String1 as string
String2 as String
End Type
Then to access the array it would be something like this:
rtn = StrData.String1(0)
So, how do I convert this to C++ and MFC?
Thanks!
Frank
|
|
|
|
|
I don't understand what rtn = StrData.String1(0) means exactly. What is the (0) there for? "String1" isn't an array.
Anyway, to make a typedef'd struct:
typedef struct
{
CString String1, String2;
} StrData;
To make an array of those, you can use a linked list (since it sounds like you don't know exactly how many structs you'll have). Use std::list<StrData> in STL, or CList<StrData, StrData&> in MFC.
|
|
|
|
|
Thanks Mike. In VB, rtn = StrData.String1(0) the (0) is the index of the n'th (where n is just a number) String1 object contained in the data type StrData. (I think)
I'm afraid I'm new to using "Linked Lists". Could you expand a bit on the usage in MFC? What do I do with the code CList<strdata, strdata&="">.
Thanks again,
Frank
|
|
|
|
|
See: http://home.socal.rr.com/samhobbs/VC/Collections.html
CStringList is really easy to use but the MFC documentation is not. I hope the example in the above page is easy though.
|
|
|
|
|
I am trying to disable two tabs that exist on a tab control with 7 total tabs. Is there anyway to disable specific tabs on with a CTabCtrl object.
|
|
|
|
|
Here are two resources for you to get the answer you want.
1. Search MSDN online (msdn.microsoft.com) for article ID: Q151662 "How To Disable Tabs in CPropertySheet"
And...
2. Paul DiLascia has an article in the March 98 issue of MSJ that covers this topic in entirety. You can search MSDN for that specific issue.
Hope that helps!
Frank
|
|
|
|
|
Can I find this article on-line? If so, where at.
|
|
|
|
|
You can search msdn at http://msdn.microsoft.com/
You can find the source code for the march issue of msdn at http://www.microsoft.com/MSJ/0398/code/MSJmar98.zip
And you can find the actual article that Paul wrote in the March 1998 issue at
http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0398/c++0398.htm
(Long URLs probably wrapped).
Hope that helps.
Frank
|
|
|
|
|
Well, folks, here we are four years down the road, and I come along (after much searching) looking for the answer to the same question that Roger had - namely, how to disable m tabs in an n-tab control (where m < n).
Unfortunately, the links given above no longer exist, which highlights the fact that it would've been nice if some clues had been given by the responder in addition to simply referencing the links.
Oh well.... another dead-end....
|
|
|
|
|
How do I develop a solution to enable spell checking on a text box using Win 32 SDK.
Looking for a ideal solution.
Thanks
Siva
|
|
|
|
|
oYou could automate Microsoft Word. Look in MSDN somewhere I think.....
|
|
|
|
|
Following code works well when compiled with Microsoft c-compiler :
j = 0;
j = (j < 1) ? j++ : 0;
--> result j = 1
When compiled with Microsoft c++ compiler
--> result = 0 (wrong)
Can somebody explain this?
|
|
|
|
|
0 is correct, use ++j if you want j to be incremented before being assigned back to itself.
You get 0 because C++ create a temporary (j) variable and increments it (and discards it in this case),
where as C doesn't bother (I think).
|
|
|
|
|
Well, the correct answer is 0. The assignment reduces to:
j = j++;
Since j++ evaluates to 0, 0 gets stuffed in j.
This is really bad programming practice, though. I hope you don't plan on writing production code this way.
|
|
|
|
|
How do I scan a registry folder?
|
|
|
|
|
Take a look at RegEnumKeyEx.
Also check help for 'Registry Functions'
regards,
Louis.
|
|
|
|
|
I am writeing a windows program that runs a file i/o function that takes a while to run, and I can't figure out how to make it update the programs window while it is running the funtion. How do I get it to run the window's window procedure in the middle of the function? (I think that is what I have to do..)
This is probably a really easy thing to fix, but I can't figure it out.
BTW this is a dialog based program (a dialog made in the resource editor) if that makes any difference..
Any help would be greatly appreciated.
Thank You.
|
|
|
|
|
Hi!
Put the following function into your dialog class
and call it in the file i/o loop. This will ensure
that the window messages are correctly disptached.
void CYourDialog::PumpMessages()
{
static MSG msg;
if( GetSafeHwnd() != NULL )
{
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if( !IsDialogMessage( &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
}
}
HTH
Holger Persch
|
|
|
|
|
|
Hi.
It looks like I am missing NAFXCWD.LIB and gets some linker errors.
Can anyone be so kind to mail me this file or tell me where to find it.
Email: patrik.andersson@kvarnstrands.se
Regards
Patrik
|
|
|
|
|
That's one of the MFC statically-linked libs. Just grab it off your VC CD and copy it to <vc6 install="" dir="">VC98\MFC\LIB.
|
|
|
|