|
Can anybody recommend some good books about MFC? I have "Programming Windows with MFC" by J.Prosise so i'd like to take step forward in the areas which that book didnt cover like database and internet/network related programming etc. etc
Any suggestions??
|
|
|
|
|
You should check out:
MFC Internals
The MFC Answer Book
I think there definite must haves.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Mike Blaszczak's book Professional MFC with Visual C++ 6 is what I read when starting with MFC. (Actually I used the edition that came out for VC 4, but the VC 6 edition should cover the same stuff, with many new sections on features added since VC 4.)
--Mike--
http://home.inreach.com/mdunn/
Push the button, Frank.
|
|
|
|
|
Agreed on The MFC Answer Book. Do NOT buy 'MFC Extensions By Example', as a lot of the examples suck. For example, the MFC Answer Book correctly shows you how you can use SetWindowPos to make a dialog that resizes to show/hide some options, but 'Extensions by example' creates TWO dialogs to solve the same problem. Ech.
The other one I like is MFC Programming with Visual C++ Unleashed. It covers everything from databasing to ATL/COM to OpenGL.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I have a wizard that I only want a title in the caption bar. I have turned off all the close box for each page of the wizard in the dialog properties box. The user should only be able to close the dialog by hitting the "Finished" button.
How can I hide the close button?
Thank.
|
|
|
|
|
You can override PreCreateWindow() and in that function remove the WM_SYSMENU style:
BOOL CWizardDlg::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style ~= WM_SYSMENU;
return CWnd::PreCreateWindow(cs);
}
this will also remove the command menu to the left of the caption along with the minimize/maximize buttons.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Thank you...That what I wanted...Over and out.
|
|
|
|
|
Hay what going up with my program. I let VC++ 6.0 Override PreCreateWindow() and then I inserted "cs.style &= ~ WM_SYSMENU;" in the body of PreCreateWindow(). I tried "cs.style ~= WM_SYSMENU;" but that wouldn't compile but "cs.style &= ~ WM_SYSMENU;" does. My problem is that I set a break point on the line I inserted and hit the debug button to run the program but my wizard was shown and the break point wasn't hit and the X box still there. Why isn't PreCreateWindow() being called?
|
|
|
|
|
I'm trying to write a function that performs some pretty natural polymorphism. It takes as a parameter a pointer to a base class object, then sets it to a new object of the subclass. In code:
void DoMorph(CBaseClass *foo)
{
foo = NULL;
foo = new CSubclass();
}
Is there an obvious reason this wouldn't compile, if CSubclass is derived from CBaseClass? I get this unexpected error:
'type cast' : conversion from 'class CSubclass *' to 'class CBaseClass *' exists, but is inaccessible.
thanks in advance,
Jake
|
|
|
|
|
Check your inheritance list in CSubclass. From MSDN --
Compiler Error C2243
'conversion type' conversion from 'type1' to 'type2' exists, but is inaccessible
A pointer to a derived class was converted to a pointer to a base class, but the derived class inherited the base class with private or protected access.
The following is an example of this error:
class B {};
class D : private B {};
D d;
B *p = &d; // error
--Mike--
http://home.inreach.com/mdunn/
Push the button, Frank.
|
|
|
|
|
Thanks for making me doublecheck that - I knew it was something obvious, but I didn't realize it was THAT obvious. I forgot the word "public". Ok, thanks.
|
|
|
|
|
I have a DLL that when I use it in VBS it works fine everytime...but when I use VB, it works the first time, but the second call returns TRASH. Can anyone explain why?? Here is a code snippet:
STDMETHODIMP CSetShare::get_pNetDiskEnum(BSTR sServer, BSTR *pVal)
{
// NetserverDiskEnum Function to
// Enumerate list of remote Server Drive Letters.
const int ENTRY_SIZE = 3; // Drive letter, colon, NULL
LPTSTR pBuf = NULL;
DWORD dwLevel = 0; // level must be zero
DWORD dwPrefMaxLen = -1;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
NET_API_STATUS nStatus;
CComBSTR cstr1;
//
// Call the NetServerDiskEnum function.
//
nStatus = NetServerDiskEnum((LPSTR)sServer,
dwLevel,
(LPBYTE *) &pBuf,
dwPrefMaxLen,
&dwEntriesRead,
&dwTotalEntries,
NULL);
//
// If the call succeeds,
//
if (nStatus == NERR_Success)
{
LPTSTR pTmpBuf;
if ((pTmpBuf = pBuf) != NULL)
{
DWORD i;
DWORD dwTotalCount = 0;
//
// Loop through the entries.
//
for (i = 0; i < dwEntriesRead; i++)
{
assert(pTmpBuf != NULL);
if (pTmpBuf == NULL)
{
// On a remote computer, only members of the
// Administrators or the Account Operators
// local group can execute NetServerDiskEnum.
//
break;
}
//
// Print drive letter for each drive;
// the number of entries actually enumerated; and
// the total number of entries available.
//
cstr1 += pTmpBuf;
pTmpBuf += ENTRY_SIZE;
dwTotalCount++;
}
cstr1 += pTmpBuf;
}
}
else
cstr1 = "System Error: No Such Machine";
if (pBuf != NULL) // Free the allocated buffer.
NetApiBufferFree(pBuf);
*pVal = (BSTR)cstr1; // Conversion to BSTR Type for VB
return S_OK;
}
Thanks in advance,
Dan
|
|
|
|
|
*pVal = (BSTR)cstr1;
There's your problem right there. cstr1 is a local variable. Change it to
*pVal = cstr1.Detach();
--Mike--
http://home.inreach.com/mdunn/
Push the button, Frank.
|
|
|
|
|
Thanks Michal, it is bed time in this part of the world...I will test this first thing in the morning, and thanks for the quick response!
Thanks in advance,
Dan
|
|
|
|
|
I have written a nice IDE for a language that I have created. The only problem I have is that when I compile it does it all through DOS. Is there a way I can capture that ouput kthe way Visual Sutdio does and show the compilation in a window?
|
|
|
|
|
Doing this is actually fairly simple; all you have to do is redirect the processes STDOUT. You can do this by creating an anonymous pipe and using the handles that are returned in a call to CreateProcess. You can then use regular file factions to read the output out of the 'read' handle.
I have some code that will do this, let me know if you'd like a copy.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Here’s my scenario: I have an application that can save/load project files. I want to be able to register the icon and file extension (*.kkp) with the system so that you can open them directly from within Explorer, and have my app load, but not try to load the project as a document. Instead, I need to be able to detect the file is a project file and then handle it myself.
I know this is possible – I even managed to do it in a previous app I was working on, but now I can’t remember how to do it. Can anybody help?
Yours,
Peter
|
|
|
|
|
I'd appreciate ANY assistance here -
My task involves displaying file properties for files my application creates. I need to figure out how to persist the data in such a way that Windows Explorer could get it (via third mouse click, Properties). I am so lost on this project, so imagine a rather stupid 10 year old trying to do this.
Thanks,
Lilian
|
|
|
|
|
|
Thank you SO much. I REALLY appreciate your reply.
You don't know how much of a weight you lifted off these shoulders.
Thanks,
Lilian
|
|
|
|
|
I'm sure glad this fourm exists..
Im trying to parse a string for "11" and put the value into a int.. here what I have so far..
CString strPDT;
strPDT = "<p>At the tone, the time will be... < b>Wednesday, Jul 11, 2001 07:57:09 PDT< /b>";
int nIndex, nFirstIndex, nSecondIndex;
nIndex = strPDT.Find(_T("tone"));
nFirstIndex = strPDT.Find("< b>", nMyIndex);
nSecondIndex = strPDT.Find(",", nFirstIndex+1);
strPDTDays = strPDT.Mid(nFirstIndex+1, nSecondIndex-FirstIndexPDT-1);
int iPDTDays = atoi(strPDTDays);
int iPDTD = iPDTDays;
I know this code isn't correct but it gives you a idea of what I'm trying to do... can someone post some code that would find "11".
Thanks again,
Rob Jones
|
|
|
|
|
For Claryfy.
You need to get the day number in the string: At the tone....?
The string has the same structure?
For example: At the tone, the time will be... + date + time
Carlos Antollini.
|
|
|
|
|
Yes I need to pull "11" from the string and at the tone.. will always stay the same.. sorry about the terrible looking post, that string that I posted has html values in it and when posted the forum didnt display the html it used the html and made the post bold.. I'll try to fix how it looks. (I Fixed how it looks)
thanks
|
|
|
|
|
Do you like this?
strPdt = "At the tone, the time will be... < b>Wednesday, Jul 11, 2001 07:57:09 PDT< /b>";
CString strTemp = strPdt.Mid(strlen("At the tone, the time will be... < b>"))
//Now you have the date and time in strTemp.
int nfirst = strTemp.Find(",");
int nSecond = strTemp.Find(",", nFirst + 1);
int iPDTDays = atoi(strTemp.Mid(nSecond - 2, 2)); //if the number is < 10 you will have " 9".
Note. I wrote the code here, check if all is OK.
Good Luck
Carlos Antollini.
|
|
|
|
|
THANKS! works great
|
|
|
|