|
-
Aug 14th, 2000, 06:05 PM
#1
Thread Starter
Addicted Member
I have used the standard message box (msgbox) and query box in one of my programs which will be distributed. However, the boxes look awful! How do I change their properties, such as font, text size, picture (to the left of the box), button picture, button size etc...
Hope someone can help me out!
Many thanks,
Steve.
Sent by: Steve Barker
E-mail: [email protected]
P.S. I KNOW 1 is not a prime!
See this thread: http://forums.vb-world.net/showthread.php?threadid=26485
-
Aug 14th, 2000, 06:36 PM
#2
Hyperactive Member
About the message box, sorry I can't be any help there. but for the query box, the almighty Aaron Young helped me a few months back. Check out this posta
http://forums.vb-world.net/showthrea...threadid=19628
-
Aug 14th, 2000, 07:35 PM
#3
You could also make a form that looks like a message box. Make a label and have a picture box. So than you can use it multiple times.
Something like:
Code:
Private Sub Form_Load()
Msgfrm.Label1.caption = "This message box was loaded thorugh the Form_Load() event."
'Msgfrm.Picture1.Picture = ...
Msgfrm.Show
End Sub
Private Sub Command1_Click()
Msgfrm.Label1.caption = "This message box was loaded thorugh the Command1_Click() event."
Msgfrm.Show
End Sub
Get the point? It's an easy way, but it will work.
-
Aug 16th, 2000, 06:10 PM
#4
Thread Starter
Addicted Member
Thanks, but...
Thanks for your help guys.
Matthew:
Wouldn't making a mock up Msgbox cause problems? How would you give focus back to the form that called the message box form? Would you use Me.Hide in the message box form? If you did, once the calling form has focus again, wouldn't it try to execute the Activate subroutine at the first possible opportunity? Apart from using Public variables as boolean flags to say whether the calling form is getting focus from IT'S calling form or from the message box, is there a way to prevent the Activate sub from re-firing?
DrewDog_21:
I'll check out the link. Thanks!
Cheers,
Steve.
Sent by: Steve Barker
E-mail: [email protected]
P.S. I KNOW 1 is not a prime!
See this thread: http://forums.vb-world.net/showthread.php?threadid=26485
-
Aug 16th, 2000, 08:57 PM
#5
Use vbModal to keep the form the only one to have the main focus.
Code:
Msgfrm.Show vbModal
vbModal will disable every form from being accessed so just the Msgfrm can be clicked, if any other one of your form's is clicked, it will beep.
And in Form_Unload, just put Unload Me. Or in the Ok Button, put that code. Something like this should make sure the same message isn't loaded twice.
Code:
Private Sub Form_Unload()
Label1.caption = ""
'and anything you want to clear
End Sub
And don't put anything in the Form_Activate event.
And you already have the events going in the other form so nothing is need in Form_Load or Form_Activate unless you a code to make it stay on top or something. You should also Center it:
Code:
Sub center(frm As Form)
'center me
frm.Left = (Screen.Width - frm.Width) / 2
frm.Top = (Screen.Height - frm.Height) / 2
End Sub
Hope that helps.
[Edited by Matthew Gates on 08-17-2000 at 02:01 AM]
-
Aug 17th, 2000, 01:57 PM
#6
Thread Starter
Addicted Member
OK!
Thanks for the help once again Matthew!
Is it bad programming practice to put stuff in the Activate event? I do it all the time! If I use Me Unload to close the message form, it will still fire the Activate event in the calling form though won't it?
Looks like I'm just going to have to use the flags to stop Activate from running each time.
Thanks again.
Cheers,
Steve.
Sent by: Steve Barker
E-mail: [email protected]
P.S. I KNOW 1 is not a prime!
See this thread: http://forums.vb-world.net/showthread.php?threadid=26485
-
Aug 17th, 2000, 04:20 PM
#7
You can put stuff in the Form_Activate event. Only it will be fired when it is called to be loaded. What flags are you using in the Active event anyway?
-
Aug 17th, 2000, 04:51 PM
#8
1 is a prime: I don't really think it's a matter of bad programming habits, rather it's a matter of what you're trying to accomplish. If you are having trouble deciding where to put your code, consider the following: (tiggered respectively)
Initialize: Triggered when an instance of a Form is created.
Load: Tiggered when a Form is loaded
Activate: Triggered when a Form becomes the Active Window.
-
Aug 18th, 2000, 02:49 AM
#9
transcendental analytic
Form_ACtivate only get's triggered once, after your form is loaded up, not when you activate your form, as deactivate never fires
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 18th, 2000, 05:13 AM
#10
-
Aug 18th, 2000, 12:28 PM
#11
transcendental analytic
you learn something new every day!
Thanks Yonatan
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 19th, 2000, 07:24 PM
#12
Thread Starter
Addicted Member
Woah! Now I'm confused! I reckon I must explained what I mean really badly. This is what I think happens regarding Activation and all that - I'll use an example I'm working on at the moment:
I have a form (call it form A) which shows information from a database. I have some code in the Activate event which initialises the database and does some other important stuff (trust me, I need this code to be in the program - it wouldn't work right if it the code was all in the Form_Load event!). There's one point in form A where another smaller form is shown (form B) over form A (the point of this form (form B) is as a kind of finder screen - all entries from one field in the database are shown in a listbox - this list can be clicked on, resulting in the smaller form vanishing. When it does, the database should have been moved to the entry chosen in form B, so that this entry is displayed on form A.) Now, form A calls form B as a modal form, because I don't want the user to be able to do other stuff until form B has been used (it does have a cancel option!). Form B is called from within a sub in form A, called, say, Caller. (So, in Sub Caller, in Form A, there is a line reading: Show.Form B vbModal.) When form B has done it's bit, I have used a Me.Hide statement in form B to set things back to form A. Now, form A carries on from where it left off, i.e. after the Show.Form_A vbModal command in the Caller sub, once Form B carries out Me.Hide. BUT - as soon as all the things have been done in the sub that called form B (Caller sub, in Form A), and the program has reached End Sub in Caller, it tries to run the Form_Activate event of Form A. Weird that it runs it after it has finished all the stuff in Caller sub huh? Well, that's what it does - try it for yourselves. (If it doesn't - PLEASE tell me, since it means I have a big problem!)
I have got around this by defining a PUBLIC boolean variable, say, FormBCalled. This is set to false at the start of the application. Just before the line Show.Form B vbModal in Caller sub of Form A, I set FormBCalled to true. (It is false by default.) At the very start of the Activate_Form event of form A, I have the following code:
Private Sub Form_Activate()
If FormBCalled = True Then
FormBCalled = False
Exit Sub
Endif
{Rest of Sub}
End Sub
Private Sub Caller()
{Code....}
FormBCalled = True
Show.FormB vbModal
{Code after Form B has got to Me.Hide}
End Sub
That was all I was trying to say! Is what I have done standard practice, or am I making things hard for myself?
Cheers guys!
Steve.
Sent by: Steve Barker
E-mail: [email protected]
P.S. I KNOW 1 is not a prime!
See this thread: http://forums.vb-world.net/showthread.php?threadid=26485
-
Aug 19th, 2000, 07:55 PM
#13
transcendental analytic
Whoah, that's much form A and B and stuff, i try to get something out of it.
As Form_Active is an event, it won't fire unless you have a dovents statement just after the Show Vbmodal call.
OR you should put a static variable in Form_active that will only let if fire once:
Code:
Private Sub Form_Activate()
Static Fireonce as boolean
If Fireonce then
exit sub
else
Fireonce=true
'Do your stuff after form is loaded
end if
Endif
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 19th, 2000, 08:44 PM
#14
Thread Starter
Addicted Member
Thanks Kedaman!
Kedaman,
Cool, I like your way of flagging better - less variables kicking about. Thanks very much. Have you tested my claim?
(I know it was lots of A's and B's, but I wanted to make sure it wasn't ambiguous!)
Cheers,
Steve.
Sent by: Steve Barker
E-mail: [email protected]
P.S. I KNOW 1 is not a prime!
See this thread: http://forums.vb-world.net/showthread.php?threadid=26485
-
Aug 20th, 2000, 02:18 PM
#15
transcendental analytic
No, what was you claim? I'm real sorry but i am weak against many A's and B's . That above was the only think i could understand, hope you don't mind i ask you to explain again
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 21st, 2000, 07:10 PM
#16
Thread Starter
Addicted Member
My claim...
Hello there! I'll try to state my claim in an easy to follow way.
Imagine you've got two forms, let's call them form 1 and form 2! (Better than A and B?)
Form 1 is on screen already, and so it's activate routine has fired once. Now, form 1 calls a second form, that's right, form 2. The code that calls form 2 is:
form2.show vbmodal
Let's say that the line of code above is located half way through a Sub called Happy(!). (Obviously, Happy is a sub in form 1.)
This causes form 2 to be displayed on top of form 1.
With me so far?
Now, form 2 does it's business, and is closed with:
me.hide
This causes form 1 to get the focus again, and form 2 vanishes with a puff of smoke. Now, this is the weird bit. The program continues to carry out the rest of the Happy sub (everything after the line "form2.show vbmodal"). This is to be expected. Now, when the code gets to the end of Happy - either an End Sub or Exit Sub command, it carries out the Form_Activate event. Hence the need for flags.
All I wanted to know is that VB is supposed to do this, and that I haven't done something really daft. Does this happed to everyone. I was hoping someone else would be able to test my claim.
Anyway, thanks for wading through yet another over complicated discussion of something quite simple! (Sorry!)
I hope this clears it up...
Cheers,
Steve.
Sent by: Steve Barker
E-mail: [email protected]
P.S. I KNOW 1 is not a prime!
See this thread: http://forums.vb-world.net/showthread.php?threadid=26485
-
Aug 22nd, 2000, 03:32 PM
#17
transcendental analytic
Yep, and that happens exactly because Form 1 won't recieve the Window message that fires Form_Activate Event.
It proceeds the message queues only if A) there is no sub running at the moment, B) if you use doevents statement.
If you use the doevents statement, it will fire the Form_Activate event, run trought it, and continue at the same position in your procedure.
Ok, was that what you wanted?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 23rd, 2000, 05:05 PM
#18
Thread Starter
Addicted Member
Thanks!
Thanks kedaman!
I'm glad that my VB is doing what it should!
So, are you saying that if you use the doevents command, it does the following: instead of the program (in my example) finishing the Happy sub, then carrying out the Activate event, it does the Activate event first and then carries on with the Happy sub from where it left off? (So, the problem of carrying out the Activate Sub is still there, it just carries it out first so that it's not looming in the background, ready to mess anything up unexpectidly at a later time, where it will be harder to trace!)
Where would you put the DoEvents command? I don't really understand this command fully.
Thanks again for your help kedaman!
Steve.
P.S. How do you include actuall VB code in these threads, so that the colours and everything are right?
Sent by: Steve Barker
E-mail: [email protected]
P.S. I KNOW 1 is not a prime!
See this thread: http://forums.vb-world.net/showthread.php?threadid=26485
-
Aug 28th, 2000, 04:23 AM
#19
transcendental analytic
Yep, you got the idea.
Doevents is there to allow other events to fire in between, usually you don't use it for this purpose, it's more used for loops which lasts more than a second so that your app won't look freezed (you can't touch any buttons until it's looped out). But for instance for a form to paint itself again it needs to recieve a WM_PAINT message so you need a doevents to do that in a busy code.
As I suggested (or did I? ) you put doevents directly after
Show.FormB vbModal
and it should also replaint the First form while in that doevents.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 29th, 2000, 06:06 PM
#20
Thread Starter
Addicted Member
Thanks!
Thanks for the help again.
Cheers,
Steve.
Sent by: Steve Barker
E-mail: [email protected]
P.S. I KNOW 1 is not a prime!
See this thread: http://forums.vb-world.net/showthread.php?threadid=26485
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|