mIRC Home    About    Download    Register    News    Help

Print Thread
DLL HELP!! #83141 16/05/04 12:44 AM
Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Feb 2004
Posts: 119
i did not get far with this DLL... was wondering if anyone could help me, with maybe 1 of the functions and i'll try and figure the rest out..

was looking at this page... but don't get how to use it..
http://msdn.microsoft.com/library/defaul...sktopwindow.asp

Code:
;
;Start's here...
;
#pragma check_stack(off)
#pragma comment(linker,"/OPT:NOWIN98")
#include <windows.h>

// general constants
#define mFunc(x) int __stdcall x(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)

// Structures
typedef struct {
DWORD mVersion;
HWND mHwnd;
BOOL mKeep;
} LOADINFO;
HWND mHWnd;

mFunc(Desktop)
{
//Sticks any window onto the desktop 
}

mFunc(UnDesktop)
{
//Put's desktop window back into mIRC 
}

mFunc(IsDesktop)
{
//Checks to see if a window is on the desktop
}

Re: DLL HELP!! #83142 16/05/04 10:49 AM
Joined: Jun 2003
Posts: 195
N
Narusegawa_Naru Offline
Vogon poet
Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
really theres no need for mfc in this case.
the functions your looking for a re SetParent and GetParent.

To make a window a desktop window you have to do 2 things.

first use SetParent using GetDesktopWindow() as the hParent and second use SetWindowLong to remove the WS_CHILD style bit. this is not done for you. something like this would work

SetParent(hWnd,GetDesktopWindow());
SetWindowLong(hWnd,GWL_STYLE,GetWindowLong(hWnd,GWL_STYLE) &~WS_CHILD);

to reverse that simply re add the WS_CHILD and set the parent back to hte previous value.

You can use if (GetParent(hWnd) == GetDesktopWindow()) to tell if its on the desktop

Have Fun smile


Have Fun smile
Re: DLL HELP!! #83143 16/05/04 12:19 PM
Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Feb 2004
Posts: 119
[code]
mFunc(Desktop)
{
//get the hwnd from mirc with something like
// $dll(my.dll,Desktop,$window($active).hwnd)
HWND mircwindow = (HWND)atoi(data);
//get the desktop hwnd
HWND dpt = GetDesktopWindow();
SetParent(mircwindow,dpt);
lstrcpy(data,"yay");
return 3;
}
[code]

and this would work for
//dll bla.dll Desktop $window(#scripting).hwnd

is this right?





Re: DLL HELP!! #83144 16/05/04 08:31 PM
Joined: Jun 2003
Posts: 195
N
Narusegawa_Naru Offline
Vogon poet
Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
dont forget to remove the WS_CHILD style bit.


Have Fun smile
Re: DLL HELP!! #83145 17/05/04 02:40 AM
Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Feb 2004
Posts: 119
"dont forget to remove the WS_CHILD style bit. " << i don't get you.. frown what do i change in the code bellow?



Code:
mFunc(Desktop)
{
//get the hwnd from mirc with something like
// $dll(my.dll,Desktop,$window($active).hwnd)
HWND mircwindow = (HWND)atoi(data);
//get the desktop hwnd
HWND dpt = GetDesktopWindow();
SetParent(mircwindow,dpt);
lstrcpy(data,"yay");
return 3;
}

Re: DLL HELP!! #83146 17/05/04 10:03 AM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Well Naru gave you two lines of example code:
SetParent(hWnd,GetDesktopWindow());
SetWindowLong(hWnd,GWL_STYLE,GetWindowLong(hWnd,GWL_STYLE) &~WS_CHILD);


And you're currently using one of them here:
SetParent(mircwindow,dpt);

So I don't think it takes too much imagination to guess that the other line is what you need:
SetWindowLong(mircwindow,GWL_STYLE,GetWindowLong(mircwindow,GWL_STYLE) &~WS_CHILD);

Then when you're setting the window as a child of mIRC again that line would (presumably) be:
SetWindowLong(mircwindow,GWL_STYLE,GetWindowLong(mircwindow,GWL_STYLE) &WS_CHILD);
Notice the missing bitwise NOT operator (~).


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: DLL HELP!! #83147 17/05/04 11:08 AM
Joined: Jun 2003
Posts: 195
N
Narusegawa_Naru Offline
Vogon poet
Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
close you would use | WS_CHILD to readd it.


Have Fun smile
Re: DLL HELP!! #83148 17/05/04 01:17 PM
Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Feb 2004
Posts: 119
OK this is what i vae now... the desktop works fine.. but can't test the undesktop and isdesktop for some reason.. When it adds the window to the desktop..ican't type anything on it. i can right click and move it around.. but can't type frown anyidea's why?

Code:
#pragma check_stack(off)
#pragma comment(linker,"/OPT:NOWIN98")
#include &lt;windows.h&gt;

// general constants
#define mFunc(x) int __stdcall x(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)

mFunc(Desktop)
{
	//get the hwnd from mirc with something like
	//echo -s $dll(hdll.dll,Desktop,$window($active).hwnd)
	HWND mircwindow = (HWND)atoi(data);
	//get the desktop hwnd
	HWND dpt = GetDesktopWindow();
	SetParent(mircwindow,dpt);
	lstrcpy(data,"S_OK");
	return 3;
}


mFunc(UnDesktop)
{
//echo -s $dll(hdll.dll,UnDesktop,$window($active).hwnd)
	HWND mircwindow = (HWND)atoi(data);
	HWND dpt = GetDesktopWindow();
	SetWindowLong(mircwindow,GWL_STYLE,GetWindowLong(mircwindow,GWL_STYLE) |WS_CHILD);
	lstrcpy(data,"S_OK");
	return 3;
}


mFunc(IsDesktop)
{
	// $dll(hdll.dll,IsDesktop,$window($active).hwnd)
	HWND mircwindow = (HWND)atoi(data);
	HWND dpt = GetDesktopWindow();
	if (GetParent(mircwindow) == dpt) 
	lstrcpy(data,"S_OK");
	return 3;
}

Re: DLL HELP!! #83149 17/05/04 03:31 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Oh yeah, that would make more sense wouldn't it. crazy


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: DLL HELP!! #83150 17/05/04 04:16 PM
Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Feb 2004
Posts: 119
"Oh yeah, that would make more sense wouldn't it. " <<< huh?

If it help's i'm using mirc 6.12 and windows XP... frown

Re: DLL HELP!! #83151 18/05/04 04:03 PM
Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Feb 2004
Posts: 119
can anyone help me please? frown

Re: DLL HELP!! #83152 18/05/04 09:47 PM
Joined: Jun 2003
Posts: 195
N
Narusegawa_Naru Offline
Vogon poet
Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
your Undesktop fn does not set the parent back to the original parent window.

as for the Isdesktop it probably would be better to test to see if the WS_CHILD style bit is currently set.

UINT style = (UINT)GetWindowLong(hwnd,GWL_STYLE);
if ((style & WS_CHILD) == WS_CHILD) //it is not a desktop window
else //it is


Have Fun smile
Re: DLL HELP!! #83153 18/05/04 09:52 PM
Joined: Jun 2003
Posts: 195
N
Narusegawa_Naru Offline
Vogon poet
Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
also in your isdektop you fill data only when it is a desktop window but do nothing if it isnt. the best thing to do would be fill it with $true and $false. this way scripters can use it in direct comparisons for example

if ($dll(blah blah)) //its a desktop window

or

if (!$dll(blah blah)) //its not a desktop window

of course the convention you use is up to you. your current setup however will always return a true value. if its not a desktop window it will return whatever data was (i.e the window handle) so they cant use the ! negate operator. again its up to you it just seems to make more sense and fits easier with mIRC script.

oops meant to edit the previous post sorry


Have Fun smile