Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Thumbs up Unanswered: SOLVED : Problem with Theme/VisualStyles in vb.net 2008

    Hi,

    I've been searching google now for 2-3 days and cant seem to find a good solution for my prob.
    Im on : VB 2008 ; Win7 (64bit) ; visualstyles/theme is ON; working on a Windows Form Application. in vb.net so no C-sharp

    Problem is the monthview and datetimepicker.

    We are developing a winform app. suitible for a touchscreen. I need a date picker to suit users fingers. Now the (i.e.) datetimepicker has a calendarfont that works if Theme/VisualStyles is turned OFF, but as we are in 2010 and not programming for win95, it wont work with Theme/VisualStyles turned on.
    I could make 1 myself, but why envent the wheel when MS allready did so (allso when its crappy, in this case)

    So in short what i need is : a datetimepicker suitible to use without a mouse/keyboard and Theme/VisualStyles turned on.
    I dont care if its ONLY turned off for THAT controle, but the rest of the form has to be/look as we are in 2010 a.d. style


    Thanks for anny suggest

    PS found this but doesnt seem to work, or im missing something ???
    Code:
     Friend Declare Unicode Function SetWindowTheme Lib "UxTheme.dll" _
        (ByVal hwnd As IntPtr, _
        ByVal pszSubAppName As String, _
        ByVal pszSubIdList As String) As Integer
    
      Private Sub EnableVisualStyles(ByVal control As Control)
        If OSFeature.Feature.IsPresent(OSFeature.Themes) Then
          SetWindowTheme(control.Handle, Nothing, Nothing)
        End If
      End Sub
    
      Private Sub DisableVisualStyles(ByVal control As Control)
        If OSFeature.Feature.IsPresent(OSFeature.Themes) Then
          SetWindowTheme(control.Handle, "", "")
        End If
      End Sub
    Last edited by Marvels; 06-08-10 at 10:37. Reason: SOLVED
    Greetz Marvels -^.^-
    Developments : VB4 Through .Net; Basic; DOS ; CNC ; Sinclair
    Databases : SQL Server Through 2005; Access 3 Through 2003 ; Oracle 8 & 9.i ;
    OS : Win 3.11 Through XP ; NortonComander ; DOS

  2. #2
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Wink SOLVED calendar display with visualstyles / theme ON

    First of all a summery for those who have the same problem but cant find the solution on the internet : vb.net MonthCalendar1 visualstyles xp Theme displayMode windows 7

    The thing I was trying to accomplish was the following :
    A . Get a monthCalendar soutible for a touchscreen
    B. with visualstyles in win7 /xp themeing ON
    C. Start the calendar in the Year modus, without the controle SDK, so that you can select the year / month/ day within 3 clicks, instead of 3 clicks to zoom out and then 3 clicks to zoom in.

    The thing is that the MonthCalendar will display 3 or more months if you stretch it out (600 by 600), if you change the font to size 32 and visualstyles is turned OFF it will display correctly.
    but if it's turned ON you just see 3 months with verry small dates, you can understand that that isn't soutible for a touchscreen. As we are in 2010 and everybody has visual styles ON
    and the view off vb in win95 was ok in 1995, it is awfull now.

    Lot of searching on Hinder-net and lots of trial on error
    But with a bit of effort it finally succeded.

    Here's the code for it (No Imports/ useing needed)

    From the calling form :
    Code:
        Dim frmToshow As frmCalendar
        frmToshow = New frmCalendar
        frmToshow.initialize()
        frmToshow.Show()
    Here is the code that displays the calendar
    Code:
    Public Class ofrmCalendar
    
      Friend Declare Unicode Function SetWindowTheme Lib "UxTheme.dll" _
       (ByVal hwnd As IntPtr, _
       ByVal pszSubAppName As String, _
       ByVal pszSubIdList As String) As Integer
    
      'Not useing this but if you need it here it is.
      Private Sub EnableVisualStyles(ByVal control As Control)
        If OSFeature.Feature.IsPresent(OSFeature.Themes) Then
          SetWindowTheme(control.Handle, Nothing, Nothing)
        End If
      End Sub
    
      Private Sub DisableVisualStyles(ByVal control As Control)
        If OSFeature.Feature.IsPresent(OSFeature.Themes) Then
          SetWindowTheme(control.Handle, "", "")
        End If
      End Sub
    
      Friend Sub initialize()
        DisableVisualStyles(Me.MonthCalendar1)
        MonthCalendar1.MinDate = Now.AddYears(-1) ' can go 1 year back to select a date    
      End Sub
    
    
      Private Sub calendar_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        MonthCalendar1.Focus()
    ' ctrl + arrow key up will zoom out once to display the month of that year
    ' so this simmulates a click on the controle to zoom out, 
    ' do it twice and you have the decade view (three times and your in year range modus)
        SendKeys.Send("^({UP})")
        SendKeys.Send("^({UP})")
    
      End Sub
    
    End Class
    success
    Last edited by Marvels; 06-08-10 at 10:44. Reason: Typo
    Greetz Marvels -^.^-
    Developments : VB4 Through .Net; Basic; DOS ; CNC ; Sinclair
    Databases : SQL Server Through 2005; Access 3 Through 2003 ; Oracle 8 & 9.i ;
    OS : Win 3.11 Through XP ; NortonComander ; DOS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •