Click here to Skip to main content
16,005,222 members
Home / Discussions / C#
   

C#

 
GeneralRe: LOC Question Pin
Brian Delahunty3-Apr-04 4:49
Brian Delahunty3-Apr-04 4:49 
GeneralRe: LOC Question Pin
Nick Parker3-Apr-04 4:37
protectorNick Parker3-Apr-04 4:37 
Generalmultiframe gif Pin
Stephane David3-Apr-04 1:40
Stephane David3-Apr-04 1:40 
GeneralRe: multiframe gif Pin
Heath Stewart3-Apr-04 4:29
protectorHeath Stewart3-Apr-04 4:29 
GeneralRe: multiframe gif Pin
Stephane David3-Apr-04 5:06
Stephane David3-Apr-04 5:06 
GeneralRe: multiframe gif Pin
Heath Stewart3-Apr-04 6:09
protectorHeath Stewart3-Apr-04 6:09 
GeneralRe: multiframe gif Pin
Stephane David3-Apr-04 7:28
Stephane David3-Apr-04 7:28 
GeneralProblem using Device Handle with P/Invoke methods Pin
Tristan Rhodes3-Apr-04 0:46
Tristan Rhodes3-Apr-04 0:46 
I have written the following code that is called from a component's paint method. The problem is, that nothing happens.

THe error codes returned from the drawthemebackground is 0, and the Rectangle method returns 1. Yet nothing happens.

However, when i draw something from the graphics object, retrieved from the same CreateGraphics method of the parent object, it draws ok.

			//Get Theme<br />
			pTHEME = ThemeAPI.OpenThemeData(this.Handle,"Window");<br />
<br />
			//Get Graphics Device Context<br />
			Graphics clientDC = this.Parent.CreateGraphics(); <br />
			IntPtr hdc = clientDC.GetHdc(); <br />
			pDC = ThemeAPI.CreateCompatibleDC(hdc);<br />
<br />
			//Get Location<br />
			Rectangle borderRect = new Rectangle(this.Location, this.Size);<br />
<br />
			//Build content Pane<br />
			ThemeAPI.Rect rect = new ThemeAPI.Rect();<br />
			rect.left = borderRect.Left - 20;<br />
			rect.top = borderRect.Top - 20;<br />
			rect.right = borderRect.Right + 20;<br />
			rect.bottom = borderRect.Bottom + 20;<br />
<br />
			//Build content Pane<br />
			ThemeAPI.Rect clipRect = new ThemeAPI.Rect();<br />
			rect.left = 0;<br />
			rect.top = 0;<br />
			rect.right = 0;<br />
			rect.bottom = 0;<br />
<br />
			int result;<br />
			int state = 1;<br />
			//Draw Background  THIS DOES NOT DRAW<br />
			for (int part=0; part<20; part++)<br />
			{<br />
				result = ThemeAPI.DrawThemeBackground(pTHEME,hdc,part,state,ref rect,ref clipRect);<br />
			}<br />
			<br />
			//Draw rectangle<br />
			result = ThemeAPI.Rectangle(pDC, borderRect.Left-5,<br />
				borderRect.Top-5, borderRect.Right+5, borderRect.Bottom+5);<br />
			//END DOES NOT DRAW<br />
<br />
			<br />
			//THIS DRAWS<br />
			Graphics clientDC2 = this.Parent.CreateGraphics();<br />
			Pen RedPen = new Pen(Color.Red, 10);<br />
			clientDC2.DrawRectangle(RedPen,borderRect);<br />
			Pen GreenPen = new Pen(Color.Green, 5);<br />
			clientDC2.DrawEllipse(GreenPen,borderRect);<br />
			clientDC2.Dispose();<br />
			//END THIS DRAWS<br />
<br />
			//Cleanup<br />
			clientDC.ReleaseHdc(hdc);


Can anyone tell me why it does not like my device handle? I've tried creating a compatible version, but it still does nothing.

I've followed the instructions to the letter, so i'm baffled. If anyone has any thoughts, they would be appreciated.

Cheers

Cata
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
Heath Stewart3-Apr-04 3:33
protectorHeath Stewart3-Apr-04 3:33 
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
Tristan Rhodes3-Apr-04 4:14
Tristan Rhodes3-Apr-04 4:14 
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
Heath Stewart3-Apr-04 4:32
protectorHeath Stewart3-Apr-04 4:32 
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
leppie3-Apr-04 6:35
leppie3-Apr-04 6:35 
GeneralShutting Down Windows Pin
Nagendra Kamath K2-Apr-04 23:32
Nagendra Kamath K2-Apr-04 23:32 
GeneralRe: Shutting Down Windows Pin
Dave Kreskowiak3-Apr-04 2:11
mveDave Kreskowiak3-Apr-04 2:11 
Questionhow to open and edit DICOM images and c# Pin
durukan2-Apr-04 22:45
durukan2-Apr-04 22:45 
AnswerRe: how to open and edit DICOM images and c# Pin
chrixian2-Apr-04 23:25
chrixian2-Apr-04 23:25 
AnswerRe: how to open and edit DICOM images and c# Pin
Dave Kreskowiak3-Apr-04 2:16
mveDave Kreskowiak3-Apr-04 2:16 
QuestionHow to Get Keyboard Control Pin
Member 6910892-Apr-04 19:44
Member 6910892-Apr-04 19:44 
AnswerRe: How to Get Keyboard Control Pin
Heath Stewart3-Apr-04 3:28
protectorHeath Stewart3-Apr-04 3:28 
GeneralBlock Size &amp; Key Size - Crypto Algorithm Pin
Danial Cox2-Apr-04 19:04
Danial Cox2-Apr-04 19:04 
GeneralRe: Block Size &amp; Key Size - Crypto Algorithm Pin
Heath Stewart3-Apr-04 3:24
protectorHeath Stewart3-Apr-04 3:24 
GeneralBuilding a reference to a control with a string Pin
mironos2-Apr-04 14:34
mironos2-Apr-04 14:34 
GeneralRe: Building a reference to a control with a string Pin
Dave Kreskowiak2-Apr-04 15:40
mveDave Kreskowiak2-Apr-04 15:40 
Generalrouter simulator code Pin
mbdcisco2-Apr-04 14:08
mbdcisco2-Apr-04 14:08 
GeneralRe: router simulator code Pin
leppie2-Apr-04 20:17
leppie2-Apr-04 20:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.