Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

API for finding screen resolution

Posted on 2002-07-24
18
Medium Priority
?
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 400 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

688 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