API for finding screen resolution

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.
ianchAsked:
Who is Participating?
 
RichWConnect With a Mentor Commented:
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
 
vinnyd79Commented:
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
 
RichWCommented:
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

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

lol

RichW
0
 
ianchAuthor Commented:
RichW
Any ideas on how I put in Subject and Body in the email?
0
 
ianchAuthor Commented:
RichW
Any ideas on how I put in Subject and Body in the email?
0
 
vinnyd79Commented:
shell "start mailto:whatever@whatever.com?Subject=Hello!&Body=" & Chr$(34) & "This is a test email" & Chr$(34), 0)
0
 
vinnyd79Commented:
Here's a function that basically does the same thing using shellexecute api.

http://www.freevbcode.com/ShowCode.Asp?ID=80
0
 
RichWCommented:
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
 
RichWCommented:
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
 
Richie_SimonettiIT OperationsCommented:
hearing...
0
 
pierrecampeCommented:
ping
0
 
ianchAuthor Commented:
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
 
vinnyd79Commented:
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
 
ianchAuthor Commented:
RichW & vinnyd79
You guys are a great team.
Is there a way I can split the points between you?
Ian
0
 
vinnyd79Commented:
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
 
ianchAuthor Commented:
RichW,
The Email code works brilliantly, thanks.

Vinny,
You're a generous man.
Ian
0
 
RichWCommented:
Vinnyd79, you're a gentleman and a scholar.

Thanks Ian.  I'm glad we could help.

RichW
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.