Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Tips & tricks

#330 - Återställ position

Postat 2000-12-25 18:44:16 av Joel i Kategori Programmering, C#, Kommandon med 0 Kommentarer

Option Explicit

Private Const APP_NAME = "LastPos"
Private Const SECTION_NAME = "Geometry"

Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type

Private Declare Function GetWindowPlacement Lib "user32" (ByVal hWnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
' Load the form's geometry from the registry.
Private Sub Form_Load()
Dim l As Single
Dim t As Single
Dim w As Single
Dim h As Single

' Load the form's last dimensions
' from the registry.
w = CSng(GetSetting(APP_NAME, SECTION_NAME, _
"Width", Format$(Width)))
h = CSng(GetSetting(APP_NAME, SECTION_NAME, _
"Height", Format$(Height)))
l = CSng(GetSetting(APP_NAME, SECTION_NAME, _
"Left", Format$(Left)))
t = CSng(GetSetting(APP_NAME, SECTION_NAME, _
"Top", Format$(Top)))
Move l, t, w, h

' Restore the window state.
WindowState = CInt(GetSetting(APP_NAME, SECTION_NAME, _
"WindowState", Format$(vbNormal)))
End Sub
' Save the form's geometry in the registry.
Private Sub Form_Unload(Cancel As Integer)
Dim wp As WINDOWPLACEMENT
Dim left_value As Single
Dim top_value As Single
Dim width_value As Single
Dim height_value As Single

' Do nothing if the form is not visible.
If Visible = False Then Exit Sub

' Get the window's normalized placement.
wp.Length = Len(wp)
GetWindowPlacement hWnd, wp

' Convert the values from pixels into twips.
left_value = wp.rcNormalPosition.Left * Screen.TwipsPerPixelX
top_value = wp.rcNormalPosition.Top * Screen.TwipsPerPixelX
width_value = (wp.rcNormalPosition.Right - wp.rcNormalPosition.Left) * Screen.TwipsPerPixelY
height_value = (wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top) * Screen.TwipsPerPixelY

' Save the dimensions.
SaveSetting APP_NAME, SECTION_NAME, _
"Left", Format$(left_value)
SaveSetting APP_NAME, SECTION_NAME, _
"Top", Format$(top_value)
SaveSetting APP_NAME, SECTION_NAME, _
"Width", Format$(width_value)
SaveSetting APP_NAME, SECTION_NAME, _
"Height", Format$(height_value)

' Save the window state.
SaveSetting APP_NAME, SECTION_NAME, _
"WindowState", Format$(WindowState)
End Sub

Sample:
Size:

Nyligen

  • 09:09 Vill du köpa medicinska tester?
  • 12:47 Vem beviljar assistansen – kommune
  • 14:17 Någon med erfarenhet av hemstädnin
  • 14:14 Bör man använda sig av en båtförme
  • 14:12 Finns det någon intressant hundblo
  • 14:25 Tips på verktyg för att skapa QR-k
  • 14:23 Tips på verktyg för att skapa QR-k
  • 20:52 Fungerer innskuddsbonuser egentlig

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 569 153
27 952
271 704
775
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies