Click here to Skip to main content
15,899,126 members

Comments by expedient.tec (Top 4 by date)

expedient.tec 7-Apr-11 5:40am View    
And many thanks for all your help!!!
expedient.tec 7-Apr-11 5:40am View    
Hi Hans,

I had renamed the class in the post above but was then getting many errors - it was as if GdipButton.cpp did not have site of GdipButton.h despite #includes I will check there order. I havent renamed the .h file - I can try that but I dont think thats the problem.

I started to do things the other way around but then the CPJNSMTPConnection code I have working in my application wasnt compiling in the GdipButton sample application. I must be doing something wrong bringing the additional code in. I would be very grateful if you could allow me to send you my modified GdipButton VS2010 solution files for you to try compiling in case you could quickly spot something?

Best regards,

Neil.
expedient.tec 6-Apr-11 9:23am View    
Hi Hans,

Many thanks for your reply - this is my first code project question and I missed the reply link at the top and only saw the add comment one at the bottom!

I tried the sample application - that compiled OK and ran - I only had to resize the dialog which had messed up the user interface (1/4 of it back & white badly drawn).

Then I followed the instructions and got this error:

...memdc.h(17): error C2011: 'CMemDC' : 'class' type redefinition
1> c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxcontrolbarutil.h(64) : see declaration of 'CMemDC'

In following the instructions, to 'Add these files to your project' I used right click on source files > add existing item for "GdipButton.cpp" and right click on header files > add existing item for "GdipButton.h" "MemDC.h" & "CGdiPlusBitmap.h" in the VS2010 solution explorer pane.

In trying to fix that I came across this question but while replacing all uses of CMemDC to YA_CMemDC cleared error C2011 I am now left with lots of errors as if GdipButton.h is not included when compiling GdipButton.cpp

the pattern of includes I have used is supposed to match the pattern I saw in the sample applications, that is:

#include "MemDC.h" placed in the dialog class .cpp file that will have the buttons and
#include "GdipButton.h" placed in the dialog class .h file that will have the buttons

I am trying to shoehorn the GDI buttons into an existing project and am hoping to avoid doing it the other way around (shoehorning in my application into the GDI Button sample).

Thanks in advance for any help.

Neil.
expedient.tec 6-Apr-11 1:55am View    
Dear Hans,

Many thanks - I had come across this in my own searching for the answer but had missed that the solution included the visual studio "dialog editor".

I neglected to use the phrase "resource editor" when trying to narrow the search down within the page - which I could have done as I programmed in GEM in the 90's and that was the standard phrase then. The following steps below take from the link you kindly passed are indeed dialog editor friendly with a trivial addition step of a load image call. I will post a comment here tomorrow explaining how I got on. Lastly I would be still interested in the query about icons on buttons - are they always destined to be annoyingly small or can you get them to be larger some how straight out of VS2010 - with no additions?

Best regards,

Neil

<snip>


Add a button to your dialog box with the resource editor, set the resource ID, and erase the text in the Caption box. You could set the style to Owner Draw, but you don’t need to because the code will automatically set this style.

Using the Class Wizard, add a variable to the ID you just created. In this example, I set the ID to IDC_PLAY, and the variable name to m_cPlay. Edit the dialog’s .h file, and change the control from CButton to CGdiButton. Don’t forget to include the file “GdipButton.h”.

In the resource editor, import the .png file from the res folder and set the resource type to PNG. Using PNG is just convention, it can be anything as long as the code matches what you name it. Right click on IDR_PNG1, select Properties, and rename it to something useful, IDR_PLAY in this example.
Step 3 – Add the LoadStdImage() function

Now, we just need to load the image to the button on initialization. In the OnInitDialg() function, add the following code near the bottom: