Re: OT slightly: VBA: Getting Window handle

what do you want to do with the image window

I guess this isn't quite a SolidWorks question. I have a form with an Image > (window) if you will. I want to get the handle for that window (hWnd). Is > this possible? I can't find anything on it. Figured i would leave it to > the pros. > > Corey Scheich
Reply to
Sean Phillips
Loading thread data ...

have a look at the 3 projects related to previews on

formatting link

Reply to
Philippe Guglielmetti

Thanks Phil, but I have already looked at them. I am not able to write anything that is not in VBA at least as far as I know, and the example that is in VBA doesn't preview DrawingDocs either, try it yourself. Maybe I am missing something. The problem seems to be that with ModelDocs and AssemblyDocs you can specify a configuration, but on DrawingDocs what would you pass for a configuration, it won't compile if you don't pass some value. On DrawingDocs I have tried passing a blank string for the config, and a Sheet name, and "Default" nothing has worked.

Corey

Reply to
Corey Scheich

Yes SW VBA

Reply to
Corey Scheich

I am sorry if I am speaking out of turn on this, but did you try the Get Preview Bitmap example (VB) in the SW API help?

Regards,

Reply to
Robert V. Hanson

Bob,

I can't locate that in the help files on my computer. This is what I am currently using

Dim previewimg As stdole.StdPicture

Set previewimg = swApp.GetPreviewBitmap(FName4, ConfigName) (I know this is in the help somewhere but I can't find it in the index or doing a search)

This is what the example that is on the SW website does. If you try their example, as I said before it works great for Parts and Assemblies but when used on drawings I get nothing. I know it must be possible. The SldWorks::PreviewDoc function is only available if called from a .dll so that idea is shot. Now I was trying to attach to the SW_PreviewBitmap.dll and I feel close but need just that extra push.

Corey

Reply to
Corey Scheich

in vb: use "Me.Hwnd" to get handle to your own window

since vba doesnt support hwnd, you'll need this API call at the top of a code module:

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

and to actually use the call (assuming you call from your own form...)

Dim windowHwnd as long windowHwnd = FindWindow(vbNullString, Me.Caption)

Reply to
rocheey

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.