Solved

API for finding screen resolution

Posted on 2002-07-24
18
210 Views
Last Modified: 2010-05-18
Anybody know the API call to find out the user's screen resolution?
As in returning 800 X 600 or 1024 X 768 etc, etc

Also API call to find out the default email program.
0
Comment
Question by:ianch
  • 6
  • 5
  • 5
  • +2
18 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 7176055
this will get the screen resolution

Private Sub Command1_Click()
Dim intWidth As Integer
Dim intHeight As Integer
intWidth = Screen.Width \ Screen.TwipsPerPixelX
intHeight = Screen.Height \ Screen.TwipsPerPixelY
MsgBox "Screen Resolution:" + vbCrLf + vbCrLf + Str$(intWidth) + " x" + Str$(intHeight), 64, "Info"
End Sub
0
 
LVL 4

Expert Comment

by:RichW
ID: 7176065
This will determine screen resolution.  No API needed:
Dim intWidth As Integer
Dim intHeight As Integer

intWidth = Screen.Width \ Screen.TwipsPerPixelX
intHeight = Screen.Height \ Screen.TwipsPerPixelY
MsgBox "Screen Resolution:" + vbCrLf + vbCrLf + Str$(intWidth) + " x" + Str$(intHeight), 64, "Info"

What do you want to do with the email code?  This code will open the default email program:

shell "start mailto:whatever@whatever.com"

RichW
0
 
LVL 4

Expert Comment

by:RichW
ID: 7176067
Damn, Vinny, I typed the answer and while looking for the email stuff you got in there before me.

lol

RichW
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:ianch
ID: 7176109
RichW
Any ideas on how I put in Subject and Body in the email?
0
 

Author Comment

by:ianch
ID: 7176133
RichW
Any ideas on how I put in Subject and Body in the email?
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 7176166
shell "start mailto:whatever@whatever.com?Subject=Hello!&Body=" & Chr$(34) & "This is a test email" & Chr$(34), 0)
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 7176176
Here's a function that basically does the same thing using shellexecute api.

http://www.freevbcode.com/ShowCode.Asp?ID=80
0
 
LVL 4

Expert Comment

by:RichW
ID: 7176916
Ok, try this one instead:

Place this in a .bas module:

Option Explicit

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    (ByVal hwnd As Long, ByVal lpOperation As String, _
    ByVal lpFile As String, ByVal lpParameters As String, _
    ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


Public Enum T_WindowStyle
    Maximized = 3
    Normal = 1
    ShowOnly = 5
End Enum


Public Sub OpenInternet(Parent As Form, URL As String, _
    WindowStyle As T_WindowStyle)
    ShellExecute Parent.hwnd, "Open", URL, "", "", WindowStyle
End Sub

Use this code in your form:

OpenInternet Me, _
"mailto:anyone@domain.com?SUBJECT=Hello World ", Normal

This will open your default email, enter the email address and the subject.

RichW
0
 
LVL 4

Expert Comment

by:RichW
ID: 7176930
Here's one that will place the email address, subject and body, AND attachment if need be.

Place this in a module:
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Place this in your form:

Public Function SendMail(ByVal MailAddress As String, ByVal MailSubject As String, ByVal MailBody As String, ByVal MailAttach As String)
    ShellExecute 0&, vbNullString, "mailto: " & MailAddress & _
    "&subject=" & MailSubject & _
    "&body=" & MailBody & _
    "&attach=" & Chr(34) & MailAttach & Chr(34) _
    , vbNullString, vbNullString, vbHide
End Function

Private Sub Form_Load()

 Call SendMail("somone@anymail.com", "The Subject", "This is the body of text.", "C:\AttachedFile.txt")

End Sub

RichW
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7177922
hearing...
0
 
LVL 6

Expert Comment

by:pierrecampe
ID: 7178270
ping
0
 

Author Comment

by:ianch
ID: 7178717
Thanks RichW,
The Shell Execute works fine with Microsoft Outlook but if I change my default email program to Outlook Express or Netscape Messenger it puts all the info (subject & body) into the email address box (the To box).
Any ideas?
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 7178817
In the SendMail function replace the "&" in front of subject with a "?".

In other words replace this line:

"&subject=" & MailSubject & _

with

"?subject=" & MailSubject & _

and it should work.

0
 

Author Comment

by:ianch
ID: 7179053
RichW & vinnyd79
You guys are a great team.
Is there a way I can split the points between you?
Ian
0
 
LVL 4

Accepted Solution

by:
RichW earned 100 total points
ID: 7179765
Thanks, ianch.  Well, you could lower the points on this thread to half and then open up another thread entitled Points For RichW at the other half.

So, you're okay now with the email code?

RichW
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 7181285
Ian,I hope we were able to answer your questions.As far as the points go,there is no need to split the points.
You can give the points to RichW on this one.

Just Glad to help
Vinny
0
 

Author Comment

by:ianch
ID: 7184006
RichW,
The Email code works brilliantly, thanks.

Vinny,
You're a generous man.
Ian
0
 
LVL 4

Expert Comment

by:RichW
ID: 7184930
Vinnyd79, you're a gentleman and a scholar.

Thanks Ian.  I'm glad we could help.

RichW
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

861 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