Home

Forums

Web development

 

 

 

 
     
 
dna88 Web development and Technology Forum
 
Profile   Register   Memberlist   Usergroups   FAQ   Search  Log in
VB form resize from client screen resulation ...

 
Post new topic   Reply to topic    dna88 Forum Index -> Programming in Java, C, C#, VB, .NET Discussion Forum
Author Message
Belal
User
User


Joined: 08 Mar 2004
Posts: 84
Location: Dhaka, Bangladesh

Post Post subject: VB form resize from client screen resulation ... Reply with quote

hello dk,

hope u r well. i need to know if it possible to make an application program that will resize all it's form's components and others when the screen resulation is being changed. hope u understand my query.......

to be more clear: u probably know, in java it can easyly be done. as in jave we have layout manager to handle such things........
Mon May 10, 04 11:34 am
Back to top
Belal View user's profile Send private message Yahoo Messenger MSN Messenger
dinangkur
Super Moderator
Super Moderator


Joined: 24 Mar 2004
Posts: 491
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

Belal,

Are you talking about an application - which change computer resolution at the time of start and on exit change back to orginal resoultion. If that is the case, I've a solution. If not, let me know.

-DK.
_________________
...we too are stardust...
Mon May 10, 04 11:59 pm
Back to top
dinangkur View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
dinangkur
Super Moderator
Super Moderator


Joined: 24 Mar 2004
Posts: 491
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

Belal,

I don't know - following code will help you or not. But the senario was:
I was developing a software for a firm, they want the application to change the resolution automatically to 600/800 and changed back to 1024/768 at the time of exit. So, I dig up and came up with a solution. I worte a module to do that.
Code:

'This module uses API Path to retrive resolution information and change it according to the requirment

'Created By: Dinangkur Kundu[dkundu@bttb.net.bd]

Option Explicit

Public Const EWX_LOGOFF = 0
Public Const EWX_SHUTDOWN = 1
Public Const EWX_REBOOT = 2
Public Const EWX_FORCE = 4
Public Const CCDEVICENAME = 32
Public Const CCFORMNAME = 32
Public Const DM_BITSPERPEL = &H40000
Public Const DM_PELSWIDTH = &H80000
Public Const DM_PELSHEIGHT = &H100000
Public Const CDS_UPDATEREGISTRY = &H1
Public Const CDS_TEST = &H4
Public Const DISP_CHANGE_SUCCESSFUL = 0
Public Const DISP_CHANGE_RESTART = 1

Public intWidth As Integer
Public intHeight As Integer

Type typDevMODE
    dmDeviceName       As String * CCDEVICENAME
    dmSpecVersion      As Integer
    dmDriverVersion    As Integer
    dmSize             As Integer
    dmDriverExtra      As Integer
    dmFields           As Long
    dmOrientation      As Integer
    dmPaperSize        As Integer
    dmPaperLength      As Integer
    dmPaperWidth       As Integer
    dmScale            As Integer
    dmCopies           As Integer
    dmDefaultSource    As Integer
    dmPrintQuality     As Integer
    dmColor            As Integer
    dmDuplex           As Integer
    dmYResolution      As Integer
    dmTTOption         As Integer
    dmCollate          As Integer
    dmFormName         As String * CCFORMNAME
    dmUnusedPadding    As Integer
    dmBitsPerPel       As Integer
    dmPelsWidth        As Long
    dmPelsHeight       As Long
    dmDisplayFlags     As Long
    dmDisplayFrequency As Long
End Type

Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lptypDevMode As Any) As Boolean
Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lptypDevMode As Any, ByVal dwFlags As Long) As Long
Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long


Public Function Resolution_Restore()
Dim typDevM As typDevMODE
Dim lngResult As Long
Dim intAns    As Integer

' Retrieve info about the current graphics mode
' on the current display device.
lngResult = EnumDisplaySettings(0, 0, typDevM)

' Set the new resolution. Don't change the color
' depth so a restart is not necessary.
With typDevM
    .dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
    .dmPelsWidth = intWidth  'ScreenWidth (640,800,1024, etc)
    .dmPelsHeight = intHeight 'ScreenHeight (480,600,768, etc)
End With

' Change the display settings to the specified graphics mode.
lngResult = ChangeDisplaySettings(typDevM, CDS_TEST)
Select Case lngResult
    Case DISP_CHANGE_RESTART
        intAns = MsgBox("You must restart your computer to apply these changes." & _
            vbCrLf & vbCrLf & "Do you want to restart now?", _
            vbYesNo + vbSystemModal, "Screen Resolution")
        If intAns = vbYes Then Call ExitWindowsEx(EWX_REBOOT, 0)
    Case DISP_CHANGE_SUCCESSFUL
        Call ChangeDisplaySettings(typDevM, CDS_UPDATEREGISTRY)
        'MsgBox "Screen resolution changed", vbInformation, "Resolution Changed"
    Case Else
        MsgBox "Mode not supported", vbSystemModal, "Error"
End Select
End Function

Public Function Resolution_Change()
Dim typDevM As typDevMODE
Dim lngResult As Long
Dim intAns    As Integer

' Retrieve info about the current graphics mode
' on the current display device.
lngResult = EnumDisplaySettings(0, 0, typDevM)

' Set the new resolution. Don't change the color
' depth so a restart is not necessary.
With typDevM
    .dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
    .dmPelsWidth = 800  'ScreenWidth (640,800,1024, etc)
    .dmPelsHeight = 600 'ScreenHeight (480,600,768, etc)
End With

' Change the display settings to the specified graphics mode.
lngResult = ChangeDisplaySettings(typDevM, CDS_TEST)
Select Case lngResult
    Case DISP_CHANGE_RESTART
        intAns = MsgBox("You must restart your computer to apply these changes." & _
            vbCrLf & vbCrLf & "Do you want to restart now?", _
            vbYesNo + vbSystemModal, "Screen Resolution")
        If intAns = vbYes Then Call ExitWindowsEx(EWX_REBOOT, 0)
    Case DISP_CHANGE_SUCCESSFUL
        Call ChangeDisplaySettings(typDevM, CDS_UPDATEREGISTRY)
        'MsgBox "Screen resolution changed", vbInformation, "Resolution Changed"
    Case Else
        MsgBox "Mode not supported", vbSystemModal, "Error"
End Select
End Function


Now you just need to put few lines of code in the initialize sub of startup form.
Code:

Dim intWidth As Integer
Dim intHeight As Integer

intWidth = Screen.Width \ Screen.TwipsPerPixelX
intHeight = Screen.Height \ Screen.TwipsPerPixelY

Call Resolution_Change



On exit put the following code to your MDI form
Code:

Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("Do You Want to Exit?", vbInformation + vbYesNo) = vbNo Then
            Cancel = 1
        Else
            Cancel = 0
            Resolution_Restore
End If
       
End Sub


Now if that is not the situation then, I think you want to resize the form and also like to resize controls on that form automatically. Then I've a OCX which will do that for you. If you need mail me.
Combining both methods you can try to hook up the application resizing according to your need. Sorry I'm don't know what or how java do that. I must start learn Java very quickly :(

-DK.
_________________
...we too are stardust...
Tue May 11, 04 3:06 am
Back to top
dinangkur View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Belal
User
User


Joined: 08 Mar 2004
Posts: 84
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

dk,

ur code is nice. and it will b helpful for me very soon. but i've got the problem running ur code in win-xp. when the mdi form runs, it successfully change the resulation to 800 by 600. but when it exit, it is not restoring the resolution i.e. not changing the resolution to 1024 by 768. what was ur program platform and if it might b a reason.

oh! my query wasn't abt that. rather what u guessed secondly, is what i like to know about. i'll make a mail to u for that, as u say.

and, i think, i've heared from quantum that now u r developing or working in java. so, i thought i might b familiar with this excelent feature of java. anyway, i've got my problem and probably have a solution of it. it's really nice.

let me know if i'm using any thing wrong in using ur module.
Wed May 12, 04 5:34 am
Back to top
Belal View user's profile Send private message Yahoo Messenger MSN Messenger
dinangkur
Super Moderator
Super Moderator


Joined: 24 Mar 2004
Posts: 491
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

I have to test the code in XP then. Let me check, I will answer shortly.

-DK.
_________________
...we too are stardust...
Wed May 12, 04 11:44 am
Back to top
dinangkur View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    dna88 Forum Index -> Programming in Java, C, C#, VB, .NET Discussion Forum All times are GMT - 7 Hours
Page 1 of 1

 

Partners and Resources

Bangladesh hosting company

Bangladesh web design

Driven by phpBB © phpBB Group