Solved

Different computers, different appearences?! VB6

Posted on 2004-08-02
22
388 Views
Last Modified: 2010-04-17
I was making a hebrew language teacher for my mom in VB6.  An image of what I want the program to look like (and what it looks like on mine) can be found at http://www.qedft.com/cached/teacher2.PNG

However, the appearance of what it looks like on the 3 other computers I tested it on can be found at http://www.qedft.com/cached/teacher2.JPG

As you can see, in the JPG file a lot of the images cut off (the hebrew writing is an image).  Can somebody please tell me why this is happening and how I can fix this (or if you only have the solution it will be enough)

Thanks  (:

--
cachedVB
0
Comment
Question by:cachedVB
  • 9
  • 8
  • 2
  • +2
22 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11699702
I guess this is a form. Form elements depends on font size. So, if different machines have different fonts then form element will be clipped.
It is better to use WinAPI bitmap functions to draw images (with clipping problems)
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11699710
they appear to be running at different resolutions i.e. 800x600 vs 1024x768
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11699712
my observation is based on the different sizing of the images.
0
 
LVL 4

Author Comment

by:cachedVB
ID: 11699715
I changed the resolutions but it didnt work.  The parts that get cutoff are not fonts, but are rather images.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11699741
>The parts that get cutoff are not fonts, but are rather images
yes I know, but the container element has been downsized in another machine. Could be 2 problems: font-size (the unit of measure) is different, or resolution is different. So, as I told you, it is better to draw bitmaps directly with WinAPI: BitBlt or StretchBlt, could be a bit messy but works fine and faster.

0
 
LVL 4

Author Comment

by:cachedVB
ID: 11699756
How can I do this? I am not familiar with API at all
0
 
LVL 3

Expert Comment

by:travisjhall
ID: 11699796
Doesn't Windows provide Hebrew language support? I know this doesn't really answer your question, but why use images for your Hebrew writing rather than just install and use Hebrew language support and fonts? Or am I misremembering and Windows does not support Hebrew?
0
 
LVL 4

Author Comment

by:cachedVB
ID: 11699806
It would take too long to install it on 30 computers... any also you can see the other images are cut off too so it doesnt matter because once i can fix one i can fix all i believe
0
 
LVL 2

Expert Comment

by:kouroshparsa
ID: 11708134
Instead of using the form background, try an image box or a picture box.
With an image box, you can easily change the size...
It should work just fine.

If did not work, go with BitBlt

As well, I think your picture has a very low resolution.
I suggest you re-create your image with a higher resolution or if you don't know how, then keep in mind,    bigger size=higher resolution
0
 
LVL 4

Author Comment

by:cachedVB
ID: 11715355
WHY IS NOONE ANSWERING MY QUESTION? I ASKED HOW DO I DO IT AND YOU JUST TELL ME USE BitBLT.
0
 
LVL 2

Expert Comment

by:kouroshparsa
ID: 11721673
To resize try this:       (0.5 is any number you want,    0.5=half)
Example:
Picture1.PaintPicture Picture1.Image, 0, 0, 0.5* Picture1.Width, 0.5*Picture1.Height, Picture1.Left, Picture1.Top, Picture1.Width, Picture1.Height
'=============
About BitBlt:
All info at this website:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_0fzo.asp

Sincerely, I once wanted to do complecated things with BitBlt...I think it is messy for your purpose and does not make any difference in your case !

You should understand the fact that if you try to make your picture bigger than its original size, no matter what you do, you never get a good quality !

Anyway, in order to use BitBlt, you need some libs in a module such as:

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 4

Author Comment

by:cachedVB
ID: 11729135
:( the first thing doesnt work and this still confuses me... can i send you the whole source and you can do it manually? If you fix it you get all the points.
0
 
LVL 2

Expert Comment

by:kouroshparsa
ID: 11729213
If you send me the hole thing, I do my best to fix it.
My whole purpose is helping you.
0
 
LVL 4

Author Comment

by:cachedVB
ID: 11729500
Where do i send it?
0
 
LVL 2

Expert Comment

by:kouroshparsa
ID: 11730529
kopack@shaw.ca
0
 
LVL 2

Expert Comment

by:kouroshparsa
ID: 11731738
I guess I know what the problem is, but why did you send me an exe file ?
Do you think I can change your exe file??? Nooooooooooooooooo
If you send me your vb code (or better vb project) I'll fix that.
By the way, you should put an exit button on your application !!!

Send me you code or I won't be able to help.
0
 
LVL 4

Author Comment

by:cachedVB
ID: 11732546
o oops i thought that was the project... my bad 1 sec
0
 
LVL 2

Expert Comment

by:kouroshparsa
ID: 11733068
As I open or run your project, I get errors because the pictures are missing.
To improve your program there are many things you should do. You don't need this many forms ? Man, I'm shocked. You should use one form and one timer and one...of everything. All your forms are the same !
I'm sure you are not deep in programming. You should try not to use any any any Global variable. It's dangerous.
Send me your pictures, I redesign the whole thing and send you my sample.
You better load the pictures when the program is running. One advantage of that is that you can always replace or add more picures to extend your program. I'm glad you used an array of pictures. That's right.
By the way did you know that pictureBox has a autosize property that you could set it to true ?!!
Try it.
0
 
LVL 2

Accepted Solution

by:
kouroshparsa earned 125 total points
ID: 11739147
I figured THE SOLUTION that work in any condition on any computer to fix the size ("clipping") problem. I send you a sample like the following.
I don't think, there is any way to directly load a picture into a variable or such a thing, so you need a hidden pictureBox (it's size does not matter) in order to load the picture temporarily in there, then you call the method I made to copy and fit it in your pictureBox.
You need: a pictureBox named HiddenPic
                                 and      Pic1
'--------Start of the fit method
Private Sub FitPictureToBox(ByVal pic_src As PictureBox, pic_dst As PictureBox)
Dim aspect_src As Single
Dim wid As Single
Dim hgt As Single

    ' Get the original picture's aspect ratio.
    aspect_src = pic_src.ScaleWidth / pic_src.ScaleHeight

    ' Get the size available.
    wid = pic_dst.ScaleWidth
    hgt = pic_dst.ScaleHeight

    ' Adjust the wid/hgt ratio to match aspect_src.
    If wid / hgt > aspect_src Then
        ' The area is too short and wide.
        ' Make it narrower.
        wid = aspect_src * hgt
    Else
        ' The area is too tall and thin.
        ' Make it shorter.
        hgt = wid / aspect_src
    End If

    ' Center the image at the correct size.
    pic_dst.Cls
    pic_dst.PaintPicture pic_src.Picture, _
        (pic_dst.ScaleWidth - wid) / 2, _
        (pic_dst.ScaleHeight - hgt) / 2, _
        wid, hgt
End Sub
'-----------------------------End
1- Try to remove all the global variables
2- Put the following at the beginning of your code for safety:   Option Explicit
2- Use one single form
3- Use a static variable so every time the user enters the right or wrong answer, it will stay in the memory (The Scope and the LifeTime of variable are 2 different things)

==========You can call the above method like this:

fname = App.Path & "\pic1.jpg"
PicHidden.Picture = LoadPicture(fname)
FitPictureToBox PicHidden, Pic1
0
 
LVL 4

Author Comment

by:cachedVB
ID: 11739995
the problem is, it will have overlap with that... i am looking for something that can maybe force the image into a particular size
0
 
LVL 2

Expert Comment

by:kouroshparsa
ID: 11745055
my code fits your picture in the pictureBox properly.
Do you want to shrink the picture as well ?
I can help you with that, but shirinking, disfigures your pictures
meaning that if one of your pictures has a much longer hight than its width (or the other way) your picture will be streched and will seem fater ot taller !
Anyway, if you want that let me know.

By the way, some programmers talked about using a hebrew font...
I'm sure you can do that. You just need to "install" a Hebrew font (you may download it).
It's not difficult, just copy your font to \WINDOWS\Fonts

If you want to do it on several computers, I still think it is worth it. You can even make your software in a way to automattically do the installation...
0
 
LVL 4

Author Comment

by:cachedVB
ID: 11747156
thats true, but I'm lazy and that works =D
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now