Click here to Skip to main content
15,920,801 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: set iTunes in Mini Player mode Pin
ianbacalla9-Aug-07 19:18
ianbacalla9-Aug-07 19:18 
QuestionConcurrency violation Problem [modified] Pin
progalx9-Aug-07 13:56
progalx9-Aug-07 13:56 
AnswerSenthil's Reply for Concurrency violation Problem Pin
Senthil S9-Aug-07 18:40
Senthil S9-Aug-07 18:40 
GeneralRe: Senthil's Reply for Concurrency violation Problem [modified] Pin
progalx10-Aug-07 3:54
progalx10-Aug-07 3:54 
QuestionColorIndex Definition Pin
ohart9-Aug-07 13:16
ohart9-Aug-07 13:16 
AnswerRe: ColorIndex Definition Pin
Johan Hakkesteegt10-Aug-07 3:08
Johan Hakkesteegt10-Aug-07 3:08 
GeneralRe: ColorIndex Definition Pin
ohart10-Aug-07 7:40
ohart10-Aug-07 7:40 
QuestionOwn control with visual styles Pin
vocaris9-Aug-07 12:14
vocaris9-Aug-07 12:14 
Hello,

I'm trying to write an own control and I want to draw the content by my self. But I have problems with the Visual Style-Support. The Visual Styles are supported and enabled for my application, but my code do nothing. Here it is:
    Protected Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)<br />
        ' open theme data<br />
        Dim hTheme As IntPtr = IntPtr.Zero<br />
        hTheme = NativeMethods.OpenThemeData(hTheme, "EDIT")<br />
<br />
        ' make sure we have a valid handle<br />
        If Not hTheme = IntPtr.Zero Then<br />
            ' get a graphics object the UxTheme can draw into<br />
            Dim hdc As IntPtr = e.Graphics.GetHdc()<br />
<br />
            ' get the draw and clipping rectangles<br />
            Dim dRect As RECT = RECT.FromRectangle(Me.ClientRectangle)<br />
            Dim cRect As RECT = RECT.FromRectangle(Me.ClientRectangle)<br />
<br />
            ' draw the themed background<br />
            Dim ret As Integer = NativeMethods.DrawThemeBackground(hTheme, hdc, 1, 1, dRect, cRect)<br />
<br />
            ' clean up resources<br />
            e.Graphics.ReleaseHdc(hdc)<br />
        End If<br />
<br />
        ' close the theme handle<br />
        NativeMethods.CloseThemeData(hTheme)<br />
    End Sub<br />
<br />
'The NativeMethods-Class<br />
<br />
Public Class NativeMethods<br />
    <DllImport("UxTheme.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _<br />
    Friend Shared Function OpenThemeData(ByVal hwnd As IntPtr, <MarshalAs(UnmanagedType.LPTStr)> ByVal pszClassList As String) As IntPtr<br />
    End Function<br />
<br />
    <DllImport("UxTheme.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _<br />
    Friend Shared Function DrawThemeBackground(ByVal hTheme As IntPtr, ByVal hdc As IntPtr, ByVal iPartId As Integer, ByVal iStateId As Integer, ByRef pRect As RECT, ByRef pClipRect As RECT) As Integer<br />
    End Function<br />
<br />
    <DllImport("UxTheme.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _<br />
    Friend Shared Function CloseThemeData(ByVal hTheme As IntPtr) As Integer<br />
    End Function<br />
End Class<br />
<br />
'The RECT-Class<br />
<br />
Imports System.Runtime.InteropServices<br />
<br />
<StructLayout(LayoutKind.Sequential)> _<br />
Public Class RECT<br />
    Public left As Integer<br />
    Public top As Integer<br />
    Public right As Integer<br />
    Public bottom As Integer<br />
<br />
    Public Sub New(ByVal left As Integer, ByVal top As Integer, ByVal right As Integer, ByVal bottom As Integer)<br />
        Me.left = left<br />
        Me.top = top<br />
        Me.right = right<br />
        Me.bottom = bottom<br />
    End Sub<br />
<br />
    Public Shared Function FromRectangle(ByVal rect As Rectangle) As RECT<br />
        Return New RECT(rect.Left, rect.Top, rect.Right, rect.Bottom)<br />
    End Function<br />
<br />
    Public Shared Function FromXYWH(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) As RECT<br />
        Return New RECT(x, y, x + width, y + height)<br />
    End Function<br />
<br />
    Public Function ToRectangle() As Rectangle<br />
        Return New Rectangle(Me.left, Me.top, Me.right - Me.left, Me.bottom - Me.top)<br />
    End Function<br />
End Class


This is a simplified implementation to draw a visual style enabled textbox, but it do nothing although no exception is thrown and the return value from DrawThemeBackground is ok. What is my mistake? I hope that onebody could help me because I tryed a few days and see no solution.

Thanks vocaris
Questionother fourms Pin
vocaris10-Aug-07 8:00
vocaris10-Aug-07 8:00 
AnswerRe: other fourms Pin
meofcourse14-Aug-07 6:32
meofcourse14-Aug-07 6:32 
QuestionWebclient Proxy server authentication failure when on alternate thread Pin
dman77779-Aug-07 8:42
dman77779-Aug-07 8:42 
QuestionNeed to Connect to UNIX server From Desktop Pin
OldDog5009-Aug-07 8:29
OldDog5009-Aug-07 8:29 
AnswerRe: Need to Connect to UNIX server From Desktop Pin
MidwestLimey13-Aug-07 7:44
professionalMidwestLimey13-Aug-07 7:44 
GeneralRe: Need to Connect to UNIX server From Desktop Pin
OldDog50017-Aug-07 3:51
OldDog50017-Aug-07 3:51 
QuestionProblem getting value Pin
TAK789-Aug-07 6:24
TAK789-Aug-07 6:24 
AnswerRe: Problem getting value Pin
Dave Kreskowiak9-Aug-07 7:55
mveDave Kreskowiak9-Aug-07 7:55 
GeneralRe: Problem getting value Pin
TAK789-Aug-07 7:58
TAK789-Aug-07 7:58 
GeneralRe: Problem getting value Pin
Dave Kreskowiak9-Aug-07 8:13
mveDave Kreskowiak9-Aug-07 8:13 
QuestionRip CD Pin
meofcourse9-Aug-07 5:22
meofcourse9-Aug-07 5:22 
AnswerRe: Rip CD Pin
Kschuler9-Aug-07 9:18
Kschuler9-Aug-07 9:18 
GeneralRe: Rip CD Pin
meofcourse9-Aug-07 9:47
meofcourse9-Aug-07 9:47 
AnswerRe: Rip CD Pin
meofcourse9-Aug-07 12:20
meofcourse9-Aug-07 12:20 
AnswerRe: Rip CD Pin
ianbacalla9-Aug-07 23:26
ianbacalla9-Aug-07 23:26 
GeneralRe: Rip CD Pin
meofcourse11-Aug-07 17:57
meofcourse11-Aug-07 17:57 
GeneralRe: Rip CD Pin
ianbacalla14-Aug-07 16:00
ianbacalla14-Aug-07 16:00 

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.