Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Publisher / Programming / January 2007

Tip: Looking for answers? Try searching our database.

How do I find the hwnd of an Image?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
schlefty - 25 Jan 2007 15:00 GMT
Here is what I am trying to do. I need to grab the color from a pixel
that I have loaded to an Image on the form.
I am using this function to grab the pixel:

Private Declare Function GetPixel Lib "GDI32" (ByVal hDC As Long, ByVal
X As Long, ByVal Y As Long) As Long
Which means that I need the hDC of the image. In order to do that I am
using this function:

Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As
Long
Which means that I need the hWnd of the image, but I can't find it
anywhere. I've tried using this function to grab it:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
But this function requires the caption of the Image, but Images in VBA
don't use captions. Is there any other way for me to find the hWnd of
the image? I can't simply use the hWnd of the form because my GetPixel
function won't grab the pixel from the image, only from the form
itself. I'm at a loss. Any help would be great.

Thanks
JoAnn Paules [MVP] - 25 Jan 2007 22:21 GMT
Wow. I've found the hex number of a color that I wanted and I didn't have to
jump thru hoops of fire with poisonous snakes slithering under them. That's
what your process sounds like to me.  :-(

Is there a reason you're going thru all of that?

Signature

JoAnn Paules
MVP Microsoft [Publisher]

~~~~~
How to ask a question
http://support.microsoft.com/KB/555375

> Here is what I am trying to do. I need to grab the color from a pixel
> that I have loaded to an Image on the form.
[quoted text clipped - 19 lines]
>
> Thanks
Ed Bennett - 25 Jan 2007 22:34 GMT
> Wow. I've found the hex number of a color that I wanted and I didn't have to
> jump thru hoops of fire with poisonous snakes slithering under them. That's
> what your process sounds like to me.  :-(
>
> Is there a reason you're going thru all of that?

Well, there's a reason this group is called .programming.

Unfortunately, I have no idea either, so it's doubtful the question is
going to get answered.

(schlefty, you are working in Microsoft Publisher VBA, yes?)

Signature

Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org

JoAnn Paules [MVP] - 26 Jan 2007 00:06 GMT
It just seems like such a long way around the process to find a color. Call
me silly.

Signature

JoAnn Paules
MVP Microsoft [Publisher]

~~~~~
How to ask a question
http://support.microsoft.com/KB/555375

>> Wow. I've found the hex number of a color that I wanted and I didn't have
>> to jump thru hoops of fire with poisonous snakes slithering under them.
[quoted text clipped - 8 lines]
>
> (schlefty, you are working in Microsoft Publisher VBA, yes?)
Ed Bennett - 26 Jan 2007 09:25 GMT
> It just seems like such a long way around the process to find a color. Call
> me silly.

Yes, but if the program needs the colour to do something with, then it
has to be able to find it on its own - it can't have you sitting there
and clicking to find the colours and then telling it. Unless you're
volunteering...

Signature

Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org

JoAnn Paules [MVP] - 26 Jan 2007 21:33 GMT
<snort!> What I know about programming would fit in a thimble and you'd
still have room for a brick.

Signature

JoAnn Paules
MVP Microsoft [Publisher]

~~~~~
How to ask a question
http://support.microsoft.com/KB/555375

>> It just seems like such a long way around the process to find a color.
>> Call me silly.
[quoted text clipped - 3 lines]
> clicking to find the colours and then telling it. Unless you're
> volunteering...
Susanne Wenzel - 26 Jan 2007 05:32 GMT
Am 25 Jan 2007 07:00:38 -0800 schrieb schlefty:

[description partially snipped]

> Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As
> Long
> Which means that I need the hWnd of the image, but I can't find it
> anywhere. I've tried using this function to grab it:

> Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
> (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
> But this function requires the caption of the Image, but Images in VBA
> don't use captions. Is there any other way for me to find the hWnd of
> the image?

I once had a similar problem, I needed the hwnd of a printer and vba did
not offer it. I used a function called CreateDC and it worked for me.

You find it here:
http://www.allapi.net/apilist/CreateDC.shtml

(But as I said, it was for a printer).

Maybe this gives you ideas. Another place to ask concerning API-Functions
is here:

microsoft.public.vb.winapi

And I recall that we once used a (grahical) program to find out about
hwnds, as far as I remember. If you're interested in the name of that
program I'll try to find out (I don't have that at home).

HTH

Greetings from Germany
Susanne
Signature

Mein System:
Office XP, SP3, aktueller Patchstand
Windows 2000, SP4, aktueller Patchstand


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.