OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-02-2011, 09:44
PAnderson PAnderson is offline
Member
 
Join Date: Nov 2003
Posts: 47
Default Form position

Is there some specific code I can add to my macros that will make a form remember its position the next time it is used?

Related to that, is there a default position for a form that works best for most PC resolutions? Would centering it in the window be best? I would love your input on this.

I should add that I tried using some of the code from a macro that John (a.k.a. runflacruiser) helped me with awhile back. However, I can't seem to get it to work. I'm not sure which part of the code specifically relates to the form positioning...or where it goes once I figure out which parts to use!

Thanks in advance,
Patti

Last edited by PAnderson; 01-02-2011 at 13:25.
Reply With Quote
  #2  
Old 01-02-2011, 17:45
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
Make sure you type a default value in the form properties area for left and top (for the form) or the move function will not work.

-John
Reply With Quote
  #3  
Old 01-02-2011, 17:52
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
Here's some form code. Don't forget to adjust the properties for the form in the properties section as I noted above or this will not work.

You can enter anything in form properties section. Ie left: 55, top: 55

Create a form called frmPatti and in it a command button called cmdGo

Add this code in form code:

Code:
Option Explicit

Private Sub cmbGo_Click()
    sms 'run the sms sub which saves any settings you want at runtime,
        'which in this case is a command button click
    
    'other subs here....
End Sub


Private Sub sms() 'save my settings (sms)
    'form position save
    'make sure you name the form whatever you want, change: frmPatti
    Dim fLeft#, fTop#
    fLeft = frmPatti.Left: fTop = frmPatti.Top
    SaveSetting "patti_form_tut", "Preferences", "form_left", fLeft
    SaveSetting "patti_form_tut", "Preferences", "form_top", fTop
End Sub


Private Sub UserForm_Initialize() 'runs when form loads

'code placed here will run when form loads
    Dim regMoveLeft, regMoveTop
    
    'get saved form positions from registry.
    regMoveLeft = GetSetting("patti_form_tut", "Preferences", "form_left")
    regMoveTop = GetSetting("patti_form_tut", "Preferences", "form_top")
    
    'move form to correct position if reg entries are not empty strings
    If regMoveLeft = "" Or regMoveTop = "" Then
       Move 55, 55
    ElseIf regMoveLeft <> "" And regMoveTop <> "" Then
        Move regMoveLeft, regMoveTop
    End If

End Sub
-John
Reply With Quote
  #4  
Old 01-02-2011, 22:05
PAnderson PAnderson is offline
Member
 
Join Date: Nov 2003
Posts: 47
Default

Thank you so much, John! I think I can figure it out now. After seeing the code outside from my other macro, things are making a little more sense now.

Patti
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
calling another form with a button in a form gorgo CorelDRAW/Corel DESIGNER VBA 1 27-05-2010 08:23
Position inch to mm GoodLook CorelDRAW/Corel DESIGNER VBA 2 11-11-2008 00:47
Position Question bprice CorelDRAW/Corel DESIGNER VBA 1 11-10-2008 20:39
Get the position of the mouse gbottesi CorelDRAW/Corel DESIGNER VBA 3 17-07-2006 20:55
Position inch to mm GoodLook Macros/Add-ons 1 31-12-1969 18:33


All times are GMT -5. The time now is 19:04.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com