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 14-05-2008, 11:22
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 433
Default Textbox in Form and Passing Control Focus.

Hello, I have a modeless box containing a text field I'd like it so that after a number is entered into the textbox and enter is pressed control is returned to the main CorelDraw application (I'm using version 12). This is the code I have for the text box (named mmMove):
Code:
Private Sub mmMove_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

Select Case KeyAscii
    Case Asc("0") To Asc("9")
    Case Asc(13)
        BringWindowToTop AppWindow.Handle
    Case Else
        KeyAscii = 0
        BringWindowToTop AppWindow.Handle
End Select
End Sub
This limits the textbox to receiving numbers and if a non-number key is pressed then CorelDraw resumes focus. The bit that's not working is when I press Enter. This doesn't hand control back to CorelDraw. Instead of Case Asc(13) I've also tried Case AscW(13) and Case vbKeySpace, but they haven't worked. How can I pass control back to CorelDraw when Enter is pressed from the textbox?

Thanks,

Chris (Hunt)
Reply With Quote
  #2  
Old 21-05-2008, 08:56
SteveDude SteveDude is offline
Senior Member
 
Join Date: Dec 2005
Location: Salina, Kansas USA
Posts: 149
Default ...

Don't use VBA that much, but did you try the API SetActiveWindow? Is KeyAscii returned as 13 on KeyPress? I had some problems with this in X4 (Never did in 12), but got around them by displaying dialogs via the API instead of using VB 6's .Show.
Reply With Quote
  #3  
Old 21-05-2008, 09:43
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 433
Default

Thanks for the reply. I don't know anything about API SetActiveWindow. How can I use it?

Chris
Reply With Quote
  #4  
Old 23-05-2008, 20:17
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

You shouldn't be using Asc(13). 13 is already a character code. If you do this, VBA would convert your number 13 into a string "13" and then get the character code of the first letter "1".

You should just put

Code:
Case 13
         ...
Alex
Reply With Quote
  #5  
Old 24-05-2008, 00:39
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 433
Default

Hi Alex, I tried that but it doesn't work. Perhaps something is wonky with my installation.

Chris
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
Passing Control From Modeless Forms knowbodynow CorelDRAW/Corel DESIGNER VBA 2 01-04-2007 10:21


All times are GMT -5. The time now is 00:25.


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