|
charu123 wrote:
How can i save the values which are entered in the dialogs say an edit button.
first, Edit button don't exist. I consider now you were talking about an Edit Box control.
CEdit* pEdit = GetDlgItem(ICD_MYEDIT); <font color=#008000>
CString strEditContent;
pEdit->GetWindowText(strEditContent); <font color=#008000>
charu123 wrote:
also how can isave values entered in combobox at runtime so that the next time i run the application the combo box gets populated with the values which were entered previously.
you must save it outside the app (file, registry...), and search for it into OnInitDialog() to fill your control with the value (SetWindowText() )
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I got it Thanks
U get wht u Give
|
|
|
|
|
I've a problem about splitters. When i want to use more than one view in a window. copy-past commands are automatically disabled and i can't use them in the applications. I use wizard to create Explorer view, to test if i do something wrong, but again they are disabled.
is there anyway to activate them automatically.
Also when i try to use ID_EDIT_COPY COMMAND from Accelerator Commands, the error message is : "Add/Remove of the function is impossible, because the parent class code is read only"
|
|
|
|
|
I have tried for some time to get a flat CCombBoxEx
There is this article on CodeProject that describes a flat ComboBox
http://www.codeproject.com/combobox/combobox_flatcombo.asp[^]
Unfortunately, I have not managed - and boy have I tried - to get it to work... Is there an easy way? What do you guys use? Is it free?
Thanks for any suggestion!
|
|
|
|
|
Every article has it's own forum, so ask there!
Don't try it, just do it!
|
|
|
|
|
hi
->how do i setfocus to a particular field on the window?
(CWnd::setfocus() always sets focus to the first field)..
->i save the user input in a text file.. when i open the file, the first character is always a garbage value.. why?
regards
pallavi
|
|
|
|
|
All your controls inherit from CWnd, so :
CEdit* pEdit = GetDlgItem(IDC_MYEDIT);
CComboBox* pCombo = GetDlgItem(IDC_MYCOMBO);
CStatic* pStatic= GetDlgItem(IDC_MYSTATIC);
<font color=#008000>
pEdit->SetFocus();
pCombo->SetFocus();
pStatic->SetFocus();
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
thanx buddy
I am a beginner in vc++ .. and used to VB programming..
thank you!
regards
pal
|
|
|
|
|
Hello,
Please tell me how can I do the following process using vc++
When I click the tree view at the left of my windows explorer bar a form should display at the right. The form should not open in the property page. It should display in the form view.
Please help me.
Thanks
goood
|
|
|
|
|
I'm trying to program something like a plugin-system although I doesn't plan to use DLL-files at the moment. I have these files:
main.cpp, plugin.h, testplugin1.h, testplugin2.h
main.cpp contains the main-function, plugin.h contains the class plugin which is just a prototype and testplugin1 and testplugin2 inherits from this. Main.cpp and plugin.h doesn't know about testplugin1 or testplugin2, these will somehow have to register themselves - and this is the problem.
I've tried to create an instance of each plugin in it own h-file:
class testplugin1 : public plugin
{
...
}
testplugin1 plugin1;
The base class plugin has a register-function which is executed in the plugins' constructor.
I thought that this was a good idea but according to VS I never reach the row:
testplugin1 plugin1;
Thus ruining the whole idea...
Is it some small thing I'm missing or am I way off, and in that case - how should this be done?
|
|
|
|
|
Is the register function declared virtual? I suspect it is and if that's true, then you broke one of C++ cardinal rules, virtual functions don't work from within the constructor. Remember, the base class(plugin) is created before the derived class(testplugin1) and so the vtable wouldn't have been setup when you're running the base class' constructor.
I'd suggest calling some base class function from the derived class, passing it "this", like
<br />
class Base<br />
{<br />
vector<Base *> v;<br />
<br />
protected:<br />
void Register(Base *b)<br />
{<br />
v.add(b);<br />
}<br />
};<br />
<br />
class Derived : public Base<br />
{<br />
public Derived()<br />
{<br />
Register(this);<br />
}<br />
};<br />
Or if you want to force derived classes to Register, you can have a Base constructor that takes Base *. Just make sure you don't call any virtual functions from within the constructor.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
The problem here is that for each derived pluggin, you will have a vector (member variable inherited from the base) that contains only one single element, that is itself... So not very usefull
You could make it static to force it to be shared among all instances of the derived pluggins but then your Register function has to be static also, and all functions that require to access this vector... Not very practical
|
|
|
|
|
S. Senthil Kumar wrote:
virtual functions don't work from within the constructor.
Unfortunately, this statement can be misconstrued. You can call a virtual function in a constructor as long as the implementation of that function exists.
So, while the following scenario is invalid (and results in a linker error since Base::foo() isn't defined)
class Base {
public:
Base() { foo(); }
virtual ~Base() { }
virtual void foo() = 0;
};
class Derived : public Base {
public:
Derived() : Base() { };
virtual ~Derived() { }
virtual void foo()
{ printf ("Derived::foo()\n"); }
}; this scenario is valid:
class Base {
public:
Base() { }
virtual ~Base() { }
virtual void foo() = 0;
};
class Derived : public Base {
public:
Derived() : Base() { foo(); };
virtual ~Derived() { }
virtual void foo()
{ printf ("Derived::foo()\n"); }
}; /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Maybe I should have said "virtual functions don't work correctly if called from the base class constructor"?
I thought it was pretty obvious though. In the second example you gave, the compiler will probably make a normal call instead of a virtual one.. If there was another class deriving from Derived and overriding foo(), then the call you made is illegal.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
Hmmm, what is the purpose of the register function ? In fact what do you want to achieve by doing this ? Something like having somewhere a 'list' of all the pluggins in your application ? (And these pluggins are 'registered' on their own creation ?)
What you could do, is manage this inside a 'pluggins manager' (or something like that) which one member function is the register function and one member variable is the list with all the vector:
class CPlugginManager
{
public:
Register(CBasePluggin* pPluggin)
{
m_Pluggins.push_back(pPluggin);
}
private:
std::vector<CBasePluggin*> m_Pluggins;
};
(something like that)
This pluggin manager is implemented as a singleton (see at the end) so that it can be accessed inside the constructors of all your derived pluggins:
CPluggin1:CPluggin1()
{
....
CPlugginManager::GetInstance()->Register(this);
};
To implement the pluggin manager as a singleton, make the constructor protected (!! IMPORTANT).
And add this:
class CPlugginManager
{
public:
static CPlugginManager* GetInstance();
protected:
CPlugginManager();
private:
static CPlugginManager* m_pInstance;
};
CPlugginManager* CPlugginManager::GetInstance()
{
if (m_pInstance==NULL)
m_pInstance = new CPlugginManager;
return m_pInstance;
};
Hope this helps (if I understood well your question )
|
|
|
|
|
Thanks for all nice suggestions!
Though there still is one thing I don't get. How do I get each plugin-class to "execute" itself? Since I don't know about the plugins in main() I can't use them there until they are stored in this register-vector - and if I don't use them in main() the thread of execution goes past the plugins and hence they don't initilize...right ? A bit of a catch-22...
|
|
|
|
|
I think it is pretty tough to do it using just C++. You need some way to discover the presence of plugins and instantiate them.. You can use COM to do that, or use reflection in .NET.. Or you could simply have dlls that are loaded automatically at startup and get scanned for the presence of certain predefined entry points..
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi,
Without using GetDiskFreeSpaceEx to get the directory space immediately.
(GetDiskFreeSpaceEx - Give Volume space)
is it in registry ??
inbha.
|
|
|
|
|
Hello,
How to select another form using tree view( When I click the icon in the tree a form should display). Please help me.
Thanks
goood
|
|
|
|
|
|
I am using a SpinButton control to let the user select a value. If the user selects a new value then I want a listctrl to immediately repaint itself to show a response to this value change. The repainting only occurs when I scroll down the list control. I am using C++ on Visual Studio 2003 .NET.
My question is how do I force the list control to repaint itself, so that I don't have to scroll up or down to get a repaint? I have tried sending messages to the list ctrl and even invalidating the client area of the list ctrl.
I am the handsome one in the crowd.
|
|
|
|
|
Invalidating only queues up paint events by adding to the accumulating invalid rectangle.
You might want to try the InvalidateRect followed by an UpdateWindow call.
|
|
|
|
|
Hi all,
I want to send packets that contains informations between computers in a local
Network but I haven't IP address of these computers.
How can I do this?
Thabks.
|
|
|
|
|
dSolariuM wrote:
...but I haven't IP address of these computers.
Use gethostbyname() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|