Solved

API for finding screen resolution

Posted on 2002-07-24
18
203 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

13 Experts available now in Live!

Get 1:1 Help Now