|
Hi,
I have changed the background color of a dialog in VC6 but having a problem.
I put CBrush m_brBakgnd in the dialog class CMyDlg;
CBrush m_brBakgnd;
Then in OnInitDialog handler of the class I called
m_brBakgnd.CreateSolidBrush(RGB(0,255,0));//green brush
And in OnCtlColor() handler i returned the brush as:
retrun m_brBakgnd;
After doing this all When dialog is displayed then Edit boxes and combox boxes are also having same background color as the dialog box, which is creating the appearace as if Edit boxes and Combo boxes are diabled.
How can I avoid Edit boxes and Combo boxes having the same background color as dialog, so that they can be shown in typical white color.
Waiting for your reply.
Best regards.
Cyber Friend
|
|
|
|
|
Are you checking that the control ID of the pWnd pointer is your dialog? If you do not check that then it will set the same color for all controls.
|
|
|
|
|
Cyber Friend wrote: How can I avoid Edit boxes and Combo boxes having the same background color as dialog, so that they can be shown in typical white color.
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
HBRUSH hbr1=CreateSolidBrush (RGB(0,255,0));
if(pWnd->GetDlgCtrlID ()==IDC_EDIT1)
return hbr;
else
return hbr1;
return hbr1;
}
I hope this helps.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi AnsShuman,
Thanx for reply.
I applied ur said method but now i m getting edit boxes ok but not combox boxes. Combo boxes are still having same background as the dialog;
here is my handler onCtlColor
HBRUSH CGeneralSettingsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbrold = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
HBRUSH hbrnew=CreateSolidBrush (RGB(206,207,206));//dark grey bkgnd
switch(pWnd->GetDlgCtrlID() )
{
case IDD_GENERALSET: // this is Id of dialog itself
break;
case IDC_LBL_GENERALSETTINGS: // main label on dialog
pDC->SetBkMode(TRANSPARENT);
break;
case IDC_ED_CHANNUM:
pDC->SetBkMode(TRANSPARENT);
return hbrold;
case IDC_COMB_PROTOCOL:
pDC->SetBkMode(TRANSPARENT);
return hbrold;
default:
break;
}
return hbrnew;
}
regards.
Cyber Friend
|
|
|
|
|
I don't see anything wrong with the code. It should function properly by not changing the background of the combo box control as you need.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi,
SetDialogBkColor worked for me .
I put this function in InitInstance() of my application and now All dialogs of my application has the same color n there is no problem wid edit boxes and combo boxes.
Thanx to all who participated in the discussion.
Cyber Friend
|
|
|
|
|
You can derived CComboBox class for your combobox and set WM_DRAWITEM for it on new class
also you can see examples on codeproject about it.
|
|
|
|
|
Hai
i want to send a string to the controller board through usb port.I have a gui application where iam controlling operations like reading adc,blinking led reading temp etc.Now i want to send a string .what i need to do
satya
|
|
|
|
|
satyanarayanarao wrote: to the controller board
Do you have an API for your board ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
|
satyanarayanarao wrote: to the controller board through usb port
USB doesn't work the same way as a serial port: you don't send data on a port but you communicate with a driver instead. And the driver is responsible for teh communication over the USB with the connected device. What kind of device is connected on the USB ? You certainly received a driver with the 'board' and you probably received documentation with it.
To communicate with the driver, you first need to get a handle through the CreateFile function then you can exchange information by using DeviceIOControl function. The code you need to pass to this function are device dependant so you need to check your documentation.
|
|
|
|
|
Hi everyone,
i need to access a private Member of a friend class from a derived class LOL
Class A with private Member AA
Class B has a Member of kind pointer on class A
So B can't access AA.
Using the friend function friend class A, the class B can access AA
All these classes are in a component, so i can't modify the source code.
Now i derive the class B and call these class for example MyB
In MyB i must also use the Pointer to the class A with his private Member.
But then i get the error : C2248
I added also the friend class A to MyB.
Anyone an idea?
Big thanks
|
|
|
|
|
C2248 isnt an error. Can you plz tell what is the error??
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Aqueel wrote: C2248 isnt an error.
Sure it is.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
C2248 = members of a derived class cannot access private members of a base class. That's all, if you cannot modify the source, then it can't be done, at least not without monumental hacking.
|
|
|
|
|
Oh thanks Christian. I am working with Visual C++ since 4 years and now i have been informed that C2248 is an error code.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Hi Aqueel,
you have two sorts of errors:
Compile Errors, which produces during the compilation, they start always with C and an ID
Then you habe Linkage-Errors, they start with LNK and an ID
Thanks Christian, so it's totally the problem of the Component-Support to resolve the problem
Thanks anyway
|
|
|
|
|
Hi Baerten Thank you. That's great to know.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
How to reduce bitmap colors from 24 bits to 256 or less?
my purpose is to save rich colored bitmap to gif file.
As I test, CxImage can not save rich colored bitmap to gif file properly because it can not reduce colors properly.
CxImage is fine to transfer 256 color bitmap to gif file.
So I need source code (similar to CxImage etc) to reduce bitmap colors first then use CxImage to transfer it to gif file.
|
|
|
|
|
GDI+ will do this for you, although it may not dither in the way you're hoping.
Dithering is the process you want, that's the word to google to get more info.
|
|
|
|
|
Hey all, Iam currently trying this small example to understand the pointers, arrays,etc. in C.
When I try executing the following , the program breaks inside fruitexec() as it would pass the list FrList sometime and not other time.
Why? Isnt the list passed the right way?
Am I pointing at differnt location?
Any help appreciated.
struct Fr_t<br />
{<br />
<br />
char * name;<br />
<br />
char * colour;<br />
<br />
};<br />
static struct Fr_t g_fr[] =<br />
{<br />
<br />
{<br />
"Apple",<br />
"pink",<br />
<br />
},<br />
{<br />
"Mango",<br />
---<br />
<br />
},<br />
<br />
{<br />
<br />
},<br />
<br />
{<br />
<br />
},<br />
{<br />
0,<br />
0,<br />
0<br />
}<br />
};<br />
<br />
struct FrList_t<br />
{<br />
char * name;<br />
} FrList_s[4];<br />
<br />
all the above structs are declared globally.<br />
<br />
<br />
<br />
static struct Fr_t* pickFr( struct Fr_t *Frtcollection, const char * name ) <br />
{<br />
struct Fr_t * what = 0;<br />
if ( Frtcollection )<br />
{<br />
<br />
for ( what = Frtcollection; what->name; ++what )<br />
{<br />
if ( strcmp( what->name, name ) == 0 )<br />
{<br />
break;<br />
}<br />
}<br />
<br />
}<br />
<br />
return ( what );<br />
}<br />
<br />
<br />
<br />
<br />
int fruitexec(int farm, struct FrList_t * Fr_List)<br />
{<br />
int next_fr = 0;<br />
struct Fr_t* fruit = 0;<br />
--------<br />
------<br />
Fr_List = & (FrList_s[next_fr])<br />
if( FrList_s[next_fr].name )<br />
{<br />
fruit = pickFr( g_fr, Fr_List->name );<br />
}<br />
<br />
printf( "The name is %s.\n", FrList_s[next_fr].name );<br />
<br />
<br />
-------<br />
---------<br />
}<br />
in main, we assign <br />
{<br />
FrList_s[0] = "Mango";<br />
FrList_s[1] = "Apple";<br />
...<br />
....fruitexec(..., Fr_List_s);<br />
}
|
|
|
|
|
thathvamsi wrote: FrList_s[0] = "Mango";
FrList_s[1] = "Apple";
where are you reserving memory for these ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
thathvamsi wrote: static struct Fr_t* pickFr( struct Fr_t *Frtcollection, const char * name )
is static here necessary ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
where do i reserve memory? and how?
if i dont put static, the warning message i get is "no predefined prototype"
|
|
|
|
|
allocating memory:
char *name;
name = new char[5];
as for the function, simply put the prototype of the funtion after your global declaration.
int myfunc(void);
bla...
int myfunc(void)
{
}
Are you writing C or C++ ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|