|
-
November 16th, 2009, 08:53 AM
#1
Implement property adding through function
Dear all,
i dont know whether the question title suite my requirement. I want write a function to set different properties of a control which take values or'd.
Like that we use in windows API's to set different properties of a window. Something like
Code:
CreateWindow( ....., ..., ..., WS_SYSTEMMENU | WS_SHOW | WS_CHILD, ...):
i know the values like WS_SHOW and all are predefined values. I want to know how can i implement this method in my control. Hope my question is clear for all. can any one help me in this.
Do rate this post if it find useful to you 
-
November 16th, 2009, 09:18 AM
#2
Re: Implement property adding through function
i dont know whether the question title suite my requirement.
Then why didn't you use a more appropriate one?
Hope my question is clear for all
Not very clear to me. What is your control? What control is that? How do you want this to work?
-
November 21st, 2009, 08:13 PM
#3
Re: Implement property adding through function
The problem is that WS_nnn are not a properties. They are window styles.
What about a property? In C++ property equivallent is called "member variable".
MFC class is not a. It merely wraps window handle and you have to have real Windows window attached to an MFC object. You will not be able to change window style by changing value of some variable of your class without calling windows API.
Mind you, not all window styles can be changed after window is created.
Just out of curiocity: what is the language you used for Windows programming before your attempt to use C++?
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
November 23rd, 2009, 08:08 AM
#4
Re: Implement property adding through function
Dear All, first of all let me apologize for misleading you guys. My question is totally different from what you guys understood. I need to implement a style management in my application similar to that used by windows in CreateWindow like functions. I need to send combination of styles to the SetStyle function of my control as we do in CreateWindow(…,WS_n1 | WS_n2 | WS_n3,… ). I have defined styles for my control like CS_SELFVALIDATE, CS_INTONLY, CS_PERSIST, CS_TRCKCHANGE etc. Now the function “SetStyle” in my control should read and understand what are the properties send by the called using | operator and make my control behave as per that.
By my understanding, each style like “CS_SELFVALIDATE” will be a int value based on bit position and I need to and that particular bit field with ‘0’ in my function to know whether that bit is on or not. Can any one clarify this and if you can send any sample code that will be more helpful for me.
Do rate this post if it find useful to you 
-
November 23rd, 2009, 09:05 AM
#5
Re: Implement property adding through function
How about an example:
Code:
#include <iostream>
using namespace std;
#define MYSTYLE1 0x0001 //bit one set
#define MYSTYLE2 0x0002 //bit two set
#define MYSTYLE3 0x0004 //bit three set
#define MYSTYLE4 0x0008 //bit four set
int main()
{
unsigned mystyle=MYSTYLE1 | MYSTYLE3;
if(mystyle&MYSTYLE1){
cout << "MYSTYLE1 is set\n";
}
if(mystyle&MYSTYLE2){
cout << "MYSTYLE2 is set\n";
}
if(mystyle&MYSTYLE3){
cout << "MYSTYLE3 is set\n";
}
if(mystyle&MYSTYLE4){
cout << "MYSTYLE4 is set\n";
}
return 0;
}
-
November 23rd, 2009, 09:20 AM
#6
Re: Implement property adding through function
Thank you verymuch this is what i was looking for :-). I will not forget to rate this :-)
Do rate this post if it find useful to you 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|