Solved

API for finding screen resolution

Posted on 2002-07-24
18
204 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 / DAO 3.6 / run time error: Couldn't find installable ISAM 7 79
using Access 8 59
Windows Script Host failed (Access is denied.) error 6 110
Help me. 3 48
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

863 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

22 Experts available now in Live!

Get 1:1 Help Now