[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

GetStockObject

Posted on 2004-10-30
5
Medium Priority
?
1,198 Views
Last Modified: 2013-12-03
I am learning programming windows.
See below piece of code:

  hdc = GetDC(hwnd);
  SelectObject(hdc,GetStockObject(DC_PEN));
  SetDCPenColor(hdc,RGB(00,0xff,00));
  ReleaseDC(hwnd, hdc);

Compiling error:
error C2065: 'DC_PEN' : undeclared identifier
error C2065: 'SetDCPenColor' : undeclared identifier

The type of stock object can be the value DC_PEN in the GetStockObject function .
what is wrong here? How should I change a pen color? Thanks.
 
0
Comment
Question by:yc_yc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 200 total points
ID: 12450737
Both DC_PEN and SetDCPenColor are available in Windows 2000 or later. To compile this code you need to define constant:

#define _WIN32_WINNT 0x0500

before including windows.h, as described in this article:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/using_the_windows_headers.asp

Put this constant to the beginning of stdafx.h.
0
 

Author Comment

by:yc_yc
ID: 12453175
In the article, it mentions another way is:

Visual C++ 6.0:  To specify compiler options, go to the Projects menu and click Settings, then select the C/C++ tab. By specifying the /D compiler option supported by Visual C++.


I tried it too. In Project settings, Select the C/C++ tab , in Project Options text box typing /D "_WIN32_WINNT 0x0500".  But it didn't work, the compiling error still exists.

Did I use the correct /D compiler option (put /D "_WIN32_WINNT 0x0500" in Project Options)? Thanks.


0
 
LVL 48

Expert Comment

by:AlexFM
ID: 12453345
/D _WIN32_WINNT=0x500    (if you add this manually to cl commang line).

Project - Settings - C/C++ - Preprocessor definitions. Add:

WIN32_WINNT=0x500
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 12453348
Correction:

_WIN32_WINNT=0x500
0
 

Author Comment

by:yc_yc
ID: 12454188
Many thanks.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question