|
Hi all!
I have the following class and i want a way to make the tree, and edit controls to have access to MAINCLASS variables.
a. Is that OK to create a constructor to each one of the controls to pass a parameter something like
Window* wn;
And use it as ((MAINCLASS *)mainwindow)->a; within class implementation ?
Or can you suggest me an other OOP way because i have read somewhere that this way to convert a base class object (mainwindow) to a derived class object is not so legal?
class MAINCLASS: public window
{
...
...
public:
//constructor
//destructor
MyTreeCtrl tc;
MyEditCtrl ec;
...
...
public:
// Variables
int a;
}
a.
// in MyTreeCtrl h
class MyTreeCtrl
{
...
...
public:
MyTreeCtrl(Window* wn)
void Foo();
...
...
public:
// Variables
Window *mainwindow;
};
// in MyTreeCtrl cpp
MyTreeCtrl::MyTreeCtrl(Window* wn)
{
mainwindow = wn;
}
MyTreeCtrl::void Foo()
{
...
int b = ((MAINCLASS *)mainwindow)->;a
...
}
Thanks!
|
|
|
|
|
one suggestion (Off Topic) : Please use code block tags for posting code. Also indent the code so it is readable.
Now about the topic.
You can use forward declaration to solve your problem.
Check this link for example : Forward declaration[^]
Regards,
Sandip.
|
|
|
|
|
Hi All
I want to set OS directory in editbox.i want to set OS directory name when my application is run.Plz help me
|
|
|
|
|
cant understand what you want?
you want to fetch os directory like
"C:\windows" or what? and set it to edit control
|
|
|
|
|
yes i want to set "C:\windows" in edit control..
Plz help me
|
|
|
|
|
GetSystemDirectory()
u can use.
SetDlgItemText for set text in Edit Control.
u can use GetWindowsDirectory() also but in xp and next it gives folder
with user name so better to use GetSystemDirectory() and extract from it.
Enjoy.![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
Use SetWindowText() (documentation here) to set the text in the edit control.
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
char lpBuffer[MAX_PATH];
UINT len = GetWindowsDirectory(lpBuffer,MAX_PATH);
SetWindowText(hWndEdit,lpBuffer);
cheers
Varghese Paul
|
|
|
|
|
|
Hello,
I had set timeout with
int n = 20000;
setsockopt(ClientSocket,SOL_SOCKET,SO_RCVTIMEO,(char*)&n,sizeof(int);
and
set mode nonblocking with function call
int iMode = 1;
ioctlsocket(ClientSocket,FIONBIO,(u_long FAR*)&iMode)
if i set mode to nonblocking than timeout is not called in recv().
but if i do it with mode blocking (default) than every thing is
working fine and timeout called.but i have to work with non blocking
mode so anybody can tell me how can i set timeout in nonblocking socket.
or why i dont get timeout ,i missed something plz reply.
Thanx in advance. 
|
|
|
|
|
Hi all,
I m using List control as Report view, there are number of columns.
i want one purticular coloumn text always show with color.
i have some fixed text for this coloumn.
text1,text2,text3,text4 are 4 diffrent fix text for coloumn.
i want text1 show in red color,text2 in green,text3 in blue,and text4 in brown.
can this possible please tellme.
if possible please explain with example.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
"_$h@nky_" wrote: can this possible please tellme.
yes
"_$h@nky_" wrote: if possible please explain with example.
search for XListCtrl on codeproject and you will get an idea of how you can do it
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
|
I have the same problem.. @_$h@nky_ .. if u have done it,plz share the solution with me.. reply asap.
|
|
|
|
|
ya its done with help of SandipG answerd link in this thread.
you can also chk and try this.
|
|
|
|
|
but the solution which you are referring to is for colouring the whole cell.. I wanted to color some substring of the text in the cell.. how could i do that from that solution.?
|
|
|
|
|
means if cell of 1 row and 1 column have string "Hello World"
you want to color whole string "Hello World" or only "Hello" or "World"
if u want color whole string "Hello World" it is possible.
but if you want color only "Hello" or "World" its not possible.
|
|
|
|
|
i want to color only Hello or world not the whole string. I think that can be feasible to do but i'm not sure how to do it.. I was thinking of using device contest to repaint the required string but i'm unable to attach the device context to the substring. If u can think of such way ..plz share your thoughts.
|
|
|
|
|
Hi all,
In EditBox Control i want to apply limit of charcters to be entered.
for example if limit is 50 characters.than:
I want if editbox have 50 charecters than after this it not enter any value.
Please tell me how can do this.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
|
Thanks
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hello everyone,
For the pattern, using reference variable as internal data member variables, I have some cercerns and want to listen to your advice whether it is real issues. I showed simple code to illustrate my idea.
My concerns are,
1. if the _buf is binded to a local variable (e.g. a local string variable), then if instance of Foo lives longer than the local variable, is it safe?
2. if the _buf is binded to a heap variable, and it is released some time but Foo does not the release operation, then using _buf is not safe?
class Foo
{
private:
string& _buf;
public:
Foo (string& input): _buf (input)
{
}
};
int main()
{
return 0;
}
thanks in advance,
George
|
|
|
|
|
George_George wrote: 1. if the _buf is binded to a local variable (e.g. a local string variable), then if instance of Foo lives longer than the local variable, is it safe?
No, you'll get an access violation when trying to use the destroyed object.
George_George wrote: 2. if the _buf is binded to a heap variable, and it is released some time but Foo does not the release operation, then using _buf is not safe?
"release"??!?
Don't you mean "deleted"?
If by "released" you mean that the object is destroyed, you'll have exactly the same problem as in #1; you'll get an access violation when you're trying to use the destroyed object. It doesn't matter whether the object is on the heap or the stack.
I suggest you use a reference counting smart pointer instead.
Just do a search here at CP, there are quite a few good examples.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks Roger,
I like your advice -- "I suggest you use a reference counting smart pointer instead.". Currently, I have another idea to fix the issue, which is do an instance copy when constructing the data member, not using a reference. Do you think it is a good idea?
regards,
George
|
|
|
|