|
Hockey wrote:
I did a little more reading an it turns out this isn't accomplished via RTTI...
Well, it isn't accomplished with C++ RTTI (dynamic_cast, typeid, typeinfo). MFC has its own RTTI invented before VC had support for C++ RTTI.
Hockey wrote:
I what I want to accomplish not dynamic creation...?
I'm not sure what do you mean here. If you want to get universal method for creating objects based on class name, you may find this article useful: http://www.microsoft.com/msj/defaulttop.asp?page=/msj/archive/S385.htm[^]
The article is titled 'Roll Your Own Persistence Implementations to Go Beyond the MFC Frontier', but dynamic creation is the base for serialization. Any reading which takes on 'factory' design pattern may also give you additional understanding of this subject.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Tomasz Sowinski wrote:
I'm not sure what do you mean here
MFC DOC/VIEW uses a form of dynamic creation when instantiating the CView/CDoc derived classes however the dynamic creation is based on the new/delete operators...???
It uses a different method in creating objects dynamically...??
It is this method I wish to learn about...not the plain jane new and delete methods...
Thanx for the URL...i'll check it out...
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hockey wrote:
MFC DOC/VIEW uses a form of dynamic creation when instantiating the CView/CDoc derived classes however the dynamic creation is based on the new/delete operators...???
In the MFC slang, 'dynamic creation' is creation of object on heap given a class name (class name as a string) at runtime. However, deep inside, it always boils down to some 'new CYourObject' in your code. The MFC magic works with macros. Basically, if you mark CYourObject with DECLARE_DYNCREATE/IMPLEMENT_DYNCREATE will have corresponding function which calls 'new CYourObject'. This function (along with class name) is hooked into list of available factory functions. Implementation of factory function is done for you by - guess what - IMPLEMENT_DYNCREATE.
So, you can look at the 'dynamic creation' problem like this: having a string with class name like 'CYourObject', you have to find a function which will call 'new CYourObject'.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
q1: Are you talking about dynamically creating an object at runtime?
q2. I think the answer to this is in MFC's Handle Maps. Have a look at CWnd::FromHandle()
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
q1: Are you talking about dynamically creating an object at runtime?
Yes I think...but NOT using new/delete
using something similar to MFC CObject but I can't use this method because I want to keep my code cross platform.
RUNTIME_CLASS macro takes a class and dynamically creates objects...I need this kinda functionality
But without MFC...
How is this accomplished...???
Thanx
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Do a search on Google for stuff like "RTTI dynamic objects/creation", "C++ Persistance" etc. Also see what the various cross-platform libraries do to handle this.
It might be a good idea to post another question here stating what you are trying to achieve and asking people how they would go about. Dynamic creation of objects isn't something you need to do very often.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
I want to write a wizard like "IE-->Internet connect wizard ",My method is that :
if (InsDWFirstDlg.DoModal ()==IDOK)
{
if (InsDWSecondDlg.DoModal ()==IDOK )
{
if (InsDWThirdDlg.DoModal ()==IDOK )
{
InsDWFourthDlg.DoModal ();
}
}
}
I find that there is twinkle
Do you have good advice or other good method ?
|
|
|
|
|
A wizard is just a property sheet with the wizard style set. Check out my hotfix checker in the System section, that's a wizard and should be a good starting point.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
thank you for your replaying .
I see it at once
|
|
|
|
|
I just got a copy of Visual Studio.net. Since I am new to programming I thought I would try building an app I have done in 6.0 so I could get a feel for the new lay out. I created a new class "CLine" for my drawing app and when I try adding functions like "CLine (CDC* pDC)" I get a message saying it's not a valid name. In 6.0 it works perfectly. Is there something I might be doing wrong? Any assistance and guidance would really be appreciated.
Thanks
|
|
|
|
|
can any body tell how to click a button using sedmessage method?
i did not know the last three parameters execpt HWND
plz explain last three parameters ?
r00d0034@yahoo.com
|
|
|
|
|
To reiterate a reply I made here:
The SendMessage function sends a message to the window procedure of a window. It doesn't return until the window fully processes the message. You should never send messages to windows of other applications because it is possible that the application may be hung and SendMessage will never return.
This is the prototype of SendMessage.
LRESULT SendMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
The hwnd parameter, as you know, is the handle to a window to which to send a message. The Msg parameter identifies what type of message to send, and the wParam and lParam parameters specify additional information about the message.
The system and applications communicate to windows via messages. Besides SendMessage, there is the PostMessage function, which sends a message to a window and returns immediately, making it ideal for communicating with windows in other applications.
To answer the second question, to programmatically simulate a button click, make the following call:
SendMessage(hwndBtn,BM_CLICK,0,0);
Peter O.
|
|
|
|
|
if the statement "using namespace" could be used to shorten the name to access to a certain function/variable.
Is there a similiar method to access to base class functions/variables in inheritance class functions , ie. to remove the front portion "base_class::" from "base_Class::base_class_func"?
|
|
|
|
|
normally you wouldnt need to explicitly qualify the base class variables and functions, unless they are static....
could you post some code?
|
|
|
|
|
You are right! I just tried to remove the front portions of it.
Before
class classOne {
public:
void functionOne()
{}
};
class classTwo: public classOne {
public:
void functionTwo()
{
classOne::functionOne();
}
};
I have removed the classOne:: from the function, and it works perfectly now. I was having some problems implementing class initially, that's why I have kept the front portion.
Thanks a million!
|
|
|
|
|
First of all Thanks for reading this post.
In my project I have a Access databse. I want to take a backup of the database file, when the user wants to , from the application.And restore it whenever user wants to.
The database file is in the current directory.
May be by a function OnBackup()
In this function i want to implement a mechanism, by which the software gets the pointer to the file (mdb file) and then save this file to his/her desired target.
I understand that this can be one by getting pointer to the file by using GetFile() function and by saving it using OnSaveDocument() function.
But then how to invoke OnFileSaveAs kind of diaolog box?
Please provide the complete detail how to do it. Or may be some source code.
Or else , suggest me some other beter mechanism to do backup/restore of a file.
|
|
|
|
|
For the file save as dialog , look up the CFileDialog class of MFC. In the constructor of the dialog box, you can specify it as an open or save dialog box.
Then you can use other win api function / or file classes for copying the mdb file.
|
|
|
|
|
Helllllo people .. i'm new in vc++ but i want to learn ... now i have a mfc mdi wizard with base class CFormView and i want to put on a new document something but in dynamic mode with Create function ... something like a button or a static text ... the problem is that i don't know where and how to do this .. i have tryed and the best result is that the button was there for a moment just and then gone .. i don't know where ... my last tryings are
CMDIChildWnd * bb=((CMDIFrameWnd*)AfxGetMainWnd())->MDIGetActive();
CButton info1;
CRect rct(50,50,200,200);
info1.Create("Info1",WS_CHILD,rct,bb,130);
info1.SetWindowText("Pleease !!!");
please help me ... and forgive my english
|
|
|
|
|
Your button object is define as a local variable,try to define a member variable to do this.
Thinking in difference!
|
|
|
|
|
Hi,
in my project (WinAPI), I have a subclassed scrollbar control. I need the arrow buttons to be drawn disabled and to draw the rest myself. And because I also need to get mouse input for the non arrow area, I subclassed the window proc and let the control draw to a memory dc (adding the WS_DIABLED style just before the redraw and removing it just after the redraw), then I draw the rest myself and blit it onto the DC it was previously supposed to be blitted to. The problems are:
1)Though the style is WM_DISABLED, I get the arrows drawn badly.
2)The right (it's a horiz bar) arrow doesn't draw at all till I click it... Dunno why. Why? I could call explicitly WM_PAINT, UpdateWindow or whatever, only the left is redrawn till I click it (and when I resize, it starts all over again)
|
|
|
|
|
I have a customer running our application on Windows XP Home version.
The program was compiled with Visual Studio V6. When the customer
accesses a specific dialog box, the program faults inside of "NTDLL.DLL".
Can anybody give me an insite as how to solve this problem? I do not have
a lot of details since this is coming from the vendor that sold the
product.
Thanks in advance for the help!
Eldon Zacek
Czech-Mate Enterprises, LLC
|
|
|
|
|
If you have spare machine on which to install Windows XP Home, do so. Then install visual studio as well. THen ghost it so you can repeat this in a matter of a few minutes when ever you need to from a CD.
Build you Application in release mode WITH debug inforamtion. When the exception occurs you then see the call stack, and work out which line in your code made it fall over.
Happy programming!!
|
|
|
|
|
Does anyone know any good resources(tutorial, sample code...) for learning about rich text boxes that aren't part of a view. Thanks.
-Ken Mazaika
|
|
|
|
|
and that isn't in a dialog box...sorry about ommitting that before.
-Ken Mazaika
|
|
|
|
|
hi all and please help,
my program have alot of "new", to initialyze my classes and member variables, and "delete" to close the app. But i found my app to be verry slow. Now a test app proved me that 5000000 "new double" takes alot of time to allocate , while a big "new double[5000000]" takes no time at all .
My question is, what is the "good" way to workout a kind of "new BYTE[5000000]" and easely manage that memory, for double, classes... normal allocations?
I think this means, big mem allocation will cause fragments and mucho "sizeof". Am i just on the wrong track
Some Links to tutorial on mem allocation is wellcome
thanks to all
|
|
|
|