|
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
|
|
|
|
|
Search MSDN for PSP_HASHELP and PSH_HASHELP
You have to remove those flags from pages/sheet to completely remove help button. You may do this in the constructor.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
I'm pretty new to ADO and need some guidence. I'm using MS Access 2K. I have
three tables. The tables looks as follows:
UserAccounts
------------
UserAcctID (key, autonumber)
UserAcctData
Queues
------
QueueID (key, autonumber)
QueueName
QueueRights
-----------
UserAcctID (foreign key)
QueueID (foreign key)
Rights
I'm using ADO and DCOM so there's potential of multiple admin users trying
to access and modify the tables at one time. I need to ensure that referential
integrity is ensured, and wondered if developers typically use locking mechanisms
or the referential integrity tool in MS Access, or both.
I also, have the following situations, and am not sure of the best way to resolve
them in terms of locking and ensuring that the keys/data won't be out of sync:
1) When one admin is editing another user's account, another admin cannot edit that
user's account. What's the best way to lock the account? Add a lock timestamp
column to UserAccounts?
Also, is this a user-friendly restriction? Do other administration program lock
another user from editing the same account, or do they allow them to edit it and
then notify them that it has changed when it's time to update and for them to reload
and redo what they've done?
2) When an admin is about to update another user's queue rights, I would need to
lock the entire "Queues" table from being added to while records are being added
or updated to the QueueRights table. What's the best way of accomplishing that?
3) Also are there any good websites and/or books that discusses how to resolve
issues with multiple users and databases?
Thanks in advance for any help!
|
|
|
|
|
Hi,
I want to use a CTabCtrl, not a propery sheet.
What I am looking for is a convenient way to design each of the tab pages, and hide & show them.
What's the common way of using a CTabCtrl to embed pages. Quite shocked by the lack of resources on this topic, or is it actually straight forward?
Cheers Again!
Richard
|
|
|
|
|
Hi
I'm new to c++ and like to know what's the difference between these two declarations:
int something[20];
and
int *something = new int[20]
delete something;
|
|
|
|
|
10 ints.
in the first sample, the 30 ints are allocated on the stack and are therefore cleaned-up automatically when the program leaves the function - so they don't live outside that function. in the second, they are allocated on the heap and you have to clean them up yourself.
one benefit of the first is automatic clean up. one benefit of the second is that the data can have a lifetime longer than that of the function that allocated it.
just a note: in general, it's not nice to allocate large amounts of memory on the stack (30 ints isn't "large").
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Thanks, now I want to check if I unterstand what you just explain
void func1()
{
int something[20];
...
}
void func2()
{
int *something = new int[20];
...
delete something;
}
In func1 the variable isn't available anymore after the function has quit, in func2 it is available even after the function has quit?
|
|
|
|
|
No, because you
a/ did not store the pointer, and
b/ deleted it.
What *is* true is if I had a vector ( an array class in the Standard Template Library ) that stored pointers to ints ( normally it would make no sense to store an int pointer, you may well, however, store a pointer to a struct or class you defined, or something like a bitmap ), then if I did this:
int i = 20;
myvector.push_back(&i);
I would be in trouble, as I would have stored the address of an int that went out of scope and was destroyed. This is one of the two dangers of pointers - if I store a memory address and the contents get deleted, if I try to use it, everything is likely to die in a hurry.
If I did this though:
int * pInt = new int;
pInt = 20;
myvector.push_back(pInt);
then I am fine - the int won't be destroyed as using a pointer put me in control of that, and memory is not leaked ( the other danger, forgetting to delete something or remember the pointer value ( the address in memory it is stored ) ) because my vector takes responsbility for storing the pointer.
The reason one might do this with large objects is because it is super fast to pass a pointer into a function, for example, because you're moving a memory location, not a huge chunk of data.
Hope that helps.
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.
|
|
|
|
|
First off, in the second function you should be using operator delete[], or else your just deleting the first allocated integer -- and thus a memory leak.
void func2() {
int * something = new int[20];
delete [] something;
}
>>>
In func1 the variable isn't available anymore after the function has quit, in func2 it is available even after the function has quit?
<<<
Almost, since you delete the array in func2 it will no longer exist. But had you not called delete the memory would have persisted even after the function went out of scope.
Doing something like this;
int * func2() {
int * something = new int[20];
return something;
}
Would preserve the allocated memory, even after the function goes out of scope.
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|