- This topic has 12 replies, 3 voices, and was last updated 18 years ago by BattleStar-Galactica.
-
AuthorPosts
-
July 6, 2006 at 8:21 pm #191469methodMember
could any one tell me step by step how to add color picker to my MFC and dialog project?Thanks
July 6, 2006 at 10:58 pm #191481BattleStar-GalacticaMemberare you learning mfc too ❓
try this
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
m_edit.SetBackColor(dlg.GetColor());this is a example to set background color of my edit control(m_edit)
July 7, 2006 at 7:25 am #191480methodMembernanomachine007 thank u for u reply. But i want be able to select any color i want, just like the attached pic.
yes i want to learn this c++ i find it more powerfull . Could u explain to me exactly how to add it to my project. I also want the color iteslf and it code appers in picture box and textbox.Thanks
July 7, 2006 at 8:36 am #191479BattleStar-GalacticaMemberare you trying that code i posted. that code product the result look like the pic. a popup color dialog. it’s not really like your pic but i just can show u like that, i am newbie too for mfc.
July 7, 2006 at 8:43 am #191478methodMemberThanks man but where should i place the code ? i created a button and placed it inside and nothing worked!!
Let me know what other refrences and controles do i need. I want to get the color code and use it later and also display both color and color code in picture box and text box but u never mentioned how !!!
AS u new i am new to this visual c++ so let me know step by step how to make your code work for my purpuse.ThanksJuly 7, 2006 at 8:48 am #191477BattleStar-GalacticaMemberdlg.GetColor();
that’s line get return color structure, check help online about CColorDialog and you will find your answer.
that’s code i put it in a button click
July 7, 2006 at 8:56 am #191476methodMember@nanomachine007 wrote:
dlg.GetColor();
that’s line get return color structure, check help online about CColorDialog and you will find your answer.
that’s code i put it in a button click
2 errors both pointing at :
m_edit.SetBackColor(dlg.GetColor());
Could also tell me how to make .exe out of this project so i be able to use it without visual studio or sending it to some one.?
Error:
Configuration: color1 - Win32 Debug
Compiling...
color1Dlg.cpp
C:colorcolor1color1Dlg.cpp(205) : error C2065: 'm_edit' : undeclared identifier
C:colorcolor1color1Dlg.cpp(205) : error C2228: left of '.SetBackColor' must have class/struct/union type
Error executing cl.exe.
color1.exe - 2 error(s), 0 warning(s)July 7, 2006 at 9:07 am #191475BattleStar-GalacticaMemberman the m_edit is a instance of my class derived from CEdit. I have created a CCustomEdit derived from CEdit blablablabal and my m_edit is an instance of CCustomeEdit blablabla.
I just show u how to make popup color dialog.
you dont need m_edit and i think loco forum is not really for mfc lol
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
yourcolorpickuphere=dlg.GetColor();I cannot give u step by step i just can give u a hint or tips man. it’s too long step by step.
July 7, 2006 at 9:11 am #191474methodMember@nanomachine007 wrote:
man the m_edit is a instance of my class derived from CEdit. I have created a CCustomEdit derived from CEdit blablablabal and my m_edit is an instance of CCustomeEdit blablabla.
I just show u how to make popup color dialog.
you dont need m_edit and i think loco forum is not really for mfc lol
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
yourcolorpickuphere=dlg.GetColor();I cannot give u step by step i just can give u a hint or tips man. it’s too long step by step.
man i just used this line inside button click event and nothing happend!!
CColorDialog dlg;
just show me how to make the color selectrd pops up and if i do selection it puts that color code inside a variable. That is all i want for now .
July 7, 2006 at 9:17 am #191473BattleStar-GalacticaMember// Get the selected color from the CColorDialog.
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
{
COLORREF color = dlg.GetColor();}
try that code in a button click dude, and i think u must go to codeproject.com to learn mfc
July 7, 2006 at 9:37 am #191472methodMember@nanomachine007 wrote:
// Get the selected color from the CColorDialog.
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
{
COLORREF color = dlg.GetColor();}
try that code in a button click dude, and i think u must go to codeproject.com to learn mfc
Thanks man . Now it pops up the color selecter but i can not use the value of color ? it keeps telling me the value is not defined when using the value of color inside send massage!! I need to get the color code after selection of color and use it inside send massage.Also how to make .exe out of this? I know i need lots of work in visual c++ i will go to that site from now one.
error:
Configuration: color1 - Win32 Debug
Compiling...
color1Dlg.cpp
C:colorcolor1color1Dlg.cpp(247) : error C2065: 'color' : undeclared identifier
Generating Code...
Compiling...
color1.cpp
Generating Code...
Error executing cl.exe.
color1.exe - 1 error(s), 0 warning(s)July 7, 2006 at 2:51 pm #191471BattleStar-GalacticaMemberhave you ever make a setup file with vb.net, it’s the same. in mfc when u buidl your project, it build automatic .exe file extension no???
to use COLORREF, you should include this header into your project Windows.h
in c++ is not the same in vb6, you have to include the header file necessary for what you want to use. but if u check help u should know it, cuz normally they tell u object name and object members and what file header should be included to your project to use that object.
read more hehehhe, i learn new thing just read the documentation. read and read it’s my advance
July 8, 2006 at 9:57 am #191470DodyMembervery shortly and very easy, download a new colorpicker class, include it in your project folder, add the .cpp and .h files into your workspace, and change the class of your button into the new class, of course with creating a new member variable, and you will be done… the picture you attached was an old program I made, and this is how I did it… so good luck
-
AuthorPosts
Related
- You must be logged in to reply to this topic.