|
i seem to have not placed my question correctly...
here is the problem. if i dont use the mfc, i seem to create the components in my program during run time. when that happens, it is my impression that i *cant* use the DIALOG editor. i shall ask this quesion:
is it possible to use the dialog editor, even though i will not use mfc?
it is also my impression that mfc will make my program easier to write but after several tries and several programs later, i still cant understand all that other stuff that gets included in my programs. that is why i think i will do better without mfc. thanks
|
|
|
|
|
I don't know if it can be done.
I would suggest again that you don't need to understand every line of code you get for free from MFC, you just need to learn bit by bit as you use them. You should also use the msdn online as much as possible, and there is a ton of online help for MFC there.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
If the question is: can I use the Resource Editor in a Win32 application, not using MFC?
The answer is: Yes, sure!
If you create a new project with AppWizard, choosing Win32 Application -> Hello World , you can see the About dialog in the project's resources and all the other resources as well.
Is there something I missed?
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Yes, you can use the resource editor without using MFC. I write programs all the time that do not use MFC but have dialogs, menus, icon, string, etc. I use the resource editor to create my dialogs, menu, icons, and string tables.
All the resource editor does is give you a graphical tool for editing the .rc files. There's no MFC involved when it comes to editing resources.
|
|
|
|
|
I thought that might be the case - how do you connect a class to the dialog template - is it just by putting in the enum
IDD = IDD_MYDIALOG
and passing IDD into the Create method ?
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
Using ATL (IDD = IDD_MYDIALOG), yes. Otherwise you have to call CreateDialog and pass in the resource ID.
HWND CreateDialog(
HINSTANCE hInstance,
LPCTSTR lpTemplate,
HWND hWndParent,
DLGPROC lpDialogFunc
);
lpTemplate
Identifies the dialog box template. This parameter is either the pointer to a null-terminated character string that specifies the name of the dialog box template or an integer value that specifies the resource identifier of the dialog box template. If the parameter specifies a resource identifier, its high-order word must be zero and its low-order word must contain the identifier. You can use the MAKEINTRESOURCE macro to create this value.
And the tricky part is to call IsDialogMessage in the message loop if you're main window is a dialog.
|
|
|
|
|
i've seen msdn and it does provide a LOT of help but not enough for me apparently...
i now see that it is possible to use the resource editor without mfc.
does it mean i can create a win32 .exe 'empty' application and i can still use the resource editor?
if the answer is yes, then i still have a few questions...
do i need to edit my own .rc file?
how do i link my class to the resource editor?
it really seems that the resource editor has no idea as to what i'm doing in my code thereby it cant see what components i'm using that is why i cant use the editor... i'm really confused.
|
|
|
|
|
Yes, you can use the resource editor without using MFC. I write programs all the time that do not use MFC but have dialogs, menus, icon, string, etc. I use the resource editor to create my dialogs, menu, icons, and string tables.
All the resource editor does is give you a graphical tool for editing the .rc files. There's no MFC involved when it comes to editing resources.
|
|
|
|
|
Yes, you can use the resource editor without using MFC. I write programs all the time that do not use MFC but have dialogs, menus, icon, string, etc. I use the resource editor to create my dialogs, menu, icons, and string tables.
All the resource editor does is give you a graphical tool for editing the .rc files. There's no MFC involved when it comes to editing resources.
|
|
|
|
|
yea u can use the resource editor without mfc, i'm a beginner too but i found out it was really easy to use mfc, u really should try it, especially when u already know a bit of visual basic its really easy. I started out with c++ with Dev-C++ (www.bloodshed.net). it doesn't have a resource editor u just have to do it manually with that one but i converted a win32 api example that show a simple window on the screen to a dialog application. i'm not going to enter the code here but you can find some help at: http://www.winprog.org/tutorial/
i will post the code here as soon as i can, i think this is a very interesting question because it was one of the first questions i asked myself too, because when u use resources for dialogs u can just draw them in the MSVC resource editor and u dont have to program everything in code + the final executable remains very small (in dev-c++ only 5kb or so, in MSVC about 24kb). I will send u both the code for dev-c++ and MSVC++ as soon as i can. i recommend u take a look at MFC and try to use the classwizard. A very helpfull tool , when u have a dialog in mfc and draw controls on it u just go to View>classwizzard> member variables and u double click the controls u want to acces, u then enter a name for the handle and press ok. fromt hat point on its as easy as VB really. for example u've drawn a textbox on a dialog and u declare a variable for it called m_hText. when u want to put something in the textbox it would look like this:
m_hText = "coffee smells bad";
UpdateData(false);
its that easy!! u just put the code where u want it to happen as in OnCreate(). UpdateData(); is used for the interaction between de member variables and the dialog. When u use UpdateData(false); the values of the member variables are displayed in the dialog, if u use UpdateData(true); the entered values in the dialog are stored in the member variables. Ugh i'm gonna stop now :p i'll just mail it
Kuniva
spidyvshades@hotmail.com
|
|
|
|
|
Hey Guys
I really need help i want to be able o convert an unsigned char array (unsigned char string) to a standard char array (char string). I need this becaue i want to put the available key stores returned from CryptGetProvParam which will only take a pointer to a unsigned char into a list box which only takes a pointer to a standard char string.
|
|
|
|
|
Doesn't cast work?
unsigned char * pBuf;
char * pString = (char *) pBuf;
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hello,
I want to be able to display a dialog (connect to database) before my view is displayed.
The dialog contains my connect information and I've included a variable based on the dialog class in my Document class.
In my main application I put following statement:
cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing;
This works fine.
I have a problem to figure out in which function I need to call the GetDocument()->m_dlg.DoModal()
I tried in OnCreate of my view, but I don't know what function to call if I press the cancel button in my dialog so I don't see any document/view. If I call return -1 in CMMyView::OnCreate, I get an error message saying that the creation of my view was not succesful.
If I put the DoModal in OnInitialUpdate I already see the docuemnt window and this is not what I want.
Please help me out on this one
Thanks
Wim Jans
|
|
|
|
|
Not sure if this will help or not, but...;)
Try overriding OnFileNew in either your Doc or your View class. More than likely in your Doc class. Just make sure you return the function to the base class so that It can finish processing it correctly.
If this tip helped it was written by me, if not I don't know who wrote it.
Frank
"Gumbercules? I love that Guy"
- Dr. Zoidberg
|
|
|
|
|
but I don't know what function to call if I press the cancel button in my dialog so I don't see any document/view.
AfxGetMainWnd()->PostMessage ( WM_CLOSE );
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
Thanks, but this doesn't work like I want it to work.
What I want is: when I choose File/new... (ctrl-n) a dialog is displayed before my mdi child window is displayed. If I close the dialog by pressing cancel, I don't want to see the child window at all. The other document child windows should sill be open however.
I tried to show the dialog in CMyView::OnCreate, but if I try to do AfxGetMainWnd()->PostMessage , I get an debug error.
Is AfxGetMainWnd()->PostMessage ( WM_CLOSE ); not closing the complete application by the way?
After that, I tried to put the code in CMyView::OnInitialUpdate, but then he already displayed my child window before showing my dialog -even if I put CView::OnInitialUpdate at the end.
I think overriding CMyView::OnCreate is perfect (with my basic knowledge so far) for what I want to do, but how can I say: ok, forget about creating this new document, I just don't have enough information. If I return -1 in OnCreate, he will complain about Failed to create empty document'.
As suggested by Frank, I tried to override the OnFileNew in my view class, but this doesn't work if I currently have no open documents. I did this by putting cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing;.
Sorry if my explanation is a bit vague, but I'm not a native English speaker.
Thanks for your time.
Wim Jans
|
|
|
|
|
A quick search of MSDN showed that OnFileNew is ACTUALLY a member of CWinApp...Try overriding it in your CWinApp derived class...
ie:
BEGIN_MESSAGE_MAP(CScribbleApp, CWinApp)
.
.
ON_COMMAND(ID_FILE_NEW, OnMyFileNew)
END_MESSAGE_MAP()
void CScribbleApp::OnMyFileNew()
{
OnFileNew();
CFrameWnd* pFrame = (CFrameWnd*)m_pMainWnd;
ASSERT_KINDOF(CFrameWnd, pFrame);
CScribbleView* pView =
(CScribbleView*)pFrame->GetActiveView();
ASSERT_KINDOF(CScribbleView, pView);
pView->GetDocument()->Initialize();
}
This example is straight out of MSDN, specifically you can search MSJ November 1996.
Hope this helps.
Frank
"-We're about to enter the heart..."
"...Where the food is digested."
-Dr. Zoidberg
|
|
|
|
|
After a night of sleep, I found the solution this morning.
I just put the code in CMyDocument::OnNewDocument
if (dlg.DoModal()!=IDOK) return FALSE;
This works, the only problem is that, if I startup the application with a new document, the dialog is displayed beffore my actual application is displayed.
I'll have a look into that.
Thanks anyway, it's good to know people spent there time helping others even on a sunday
Wim
|
|
|
|
|
can anyone please tell me what the simplest way is to see if a ceratin string is in another CString, for example:
i have a CString with value: "coffee smells terrible"
and i want to see if "err" is in that string(in "terrible"), how do i do that?
thanx
Kun
|
|
|
|
|
You can use the Find function of CString. So you would have something like this:
int pos;
CString buffer;
buffer = "coffee smells terrible";
pos = buffer.Find("err");
if(pos != -1)
{
}
This should work for both MFC and WTL.
Steve Maier, MCSD
|
|
|
|
|
|
CString strCoffee = "coffee smells terrible";
int iSearch = strCoffee.find("err");
if (iSearch != -1)
{
//found it.
}
else
{
//couldn't find it.
}
|
|
|
|
|
Ummm, you got the method name case wrong...
CString sBuffer(_T("The coffee smells terrible"));
if (sBuffer.Find("err") >= 0)
{
}
else
{
}
Also, keep in mind that string searches in a CString are case-sensitive, so if that matters, you may want to use the CString::MakeLower() function befoire running your search.
|
|
|
|
|
Hi,
How to totally remove the help button from a wizard
(CPropertySheetEx)? thanks.
p.c.
|
|
|
|
|
One Way:
BOOL CMyPropertySheet::OnInitDialog()
{
CPropertySheetEx::OnInitDialog();
// this hides the Help button
CWnd* pHelpButton = GetDlgItem (IDHELP);
ASSERT (pHelpButton);
if (pHelpButton)
pHelpButton->ShowWindow (SW_HIDE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Bill
|
|
|
|