The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Handle of the window
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

jonni

United Kingdom
58 Posts

Posted - 11/26/2003 :  12:54:02 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I want to create and place my own visual component, for example, on the graph window. In order to do it i have to know a Handle of the graph window.
basically I want to use API call: SetParent(myhandel,Graphhandle)

is it possible to do it?
or any other ways to achive this?

is it possible to use from OriginC API functions?
(for example RegisterClasseEx,CreateWindowsEx,SetParent: i'm still going into creating my own visual component on the grap window :) )

cpyang

USA
1406 Posts

Posted - 11/26/2003 :  1:10:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you just want to have access to the window handle of an Origin graph, the following will show you how to Post a message to a given graph window,




// following const not yet defined in Origin C
#define WM_SYSCOMMAND 0x0112
#define SC_MINIMIZE 0xF020

void Test(string strGraphWinName = "Graph1")
{
GraphPage gp(strGraphWinName);
if(gp)
{
HANDLE hWnd = gp.GetWindow().GetSafeHwnd();
if(hWnd)
{
MessageBox(hWnd, strGraphWinName + " will be minimized next", "Hello World", MB_OK);
Window wnd(hWnd);
wnd.PostMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
}
}



Go to Top of Page

jonni

United Kingdom
58 Posts

Posted - 11/26/2003 :  1:19:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thanks a lot, almost what I wanted..
will tray.

how about using API functions in OriginC programming?
is it possible just include windows.h, messages.h (i need just 2 of that *.h files)?
Go to Top of Page

jonni

United Kingdom
58 Posts

Posted - 11/26/2003 :  1:28:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear cpyang,

Porblems :(

I tried to do what you suggested

error during compilation
GraphPage::GetWindow() not defined or does not have matching prototype

what to do?
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 11/26/2003 :  1:56:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Which version of Origin are you using? Can you look into mswin.h in system folder? The method should be introduced in 70SR4, and certainly in Origin7.5.

If you need call other API, best would be to create your own header and add the needed #define and prototypes as you see fit. You can look at mswin.h to see how it was done. You can search for

#pragma dll(kernel32, system)
#pragma dll(User32, system)


CP




Go to Top of Page

jonni

United Kingdom
58 Posts

Posted - 11/26/2003 :  2:25:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
ok... I updated My Origin to the 70SR4

now i can compile your code without problem

but when I try to run it: Command Error!

I did absolytelly the same in Origin7.5 evalution just to test and it works fine.



Edited by - jonni on 11/26/2003 2:25:59 PM
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 11/26/2003 :  3:41:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Probably PostMessage not implemented in 70SR4, but you don't need that anyway, just to show that you can get the correct handle to a window.

CP


Go to Top of Page

jonni

United Kingdom
58 Posts

Posted - 11/26/2003 :  3:47:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
1. --------------------

i have windows.h

#include<windows.h>
I want to use API calls declared in this file.

Origin7 SP4:
can compile in originC with this include and have access to all functiuons, but can not to run anything (even empti void Test() {} : CommandError) it happened after installing SP4

Origin7.5:
can not even compile... problem with syntax error in procompile #if , #endif....

2. --------------------
void Test()
{
#pragma dll(user32, system)
FindWindow("Class",NULL);
}

Compilation: the function FindWindow is not found :( but it is defined in user32.dll

trying to use #include <winuser.h> where the function FindWindow is declared...
a lot of problem during compilation

is any mistakes in my code??
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 11/26/2003 :  4:03:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I don't think you can directly include a huge header like windows.h, since it include many many other headers and they all need to be found and there are probably things not compatible in Origin C.

You will need to add the needed protypes into a header that will provide needed functions. For example, to use FindWindow, you need

#pragma dll(user32, system)
#define FindWindow FindWindowA
HWND WINAPI FindWindowA(LPCSTR lpClassName , LPCSTR lpWindowName);

and put above into a separate header file.
The above information can be found in WinUser.h from VC.


CP


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000