HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Control Insertion API (c++ library)

04-11-2007, 10:00 PM#1
Mapz_Maker
I had been trying to insert a control into another window with C# for a long time. So i asked around on ms's C# forum and found out i needed an unmanaged language to program such an api in. So, i have to turned to C++. the thing is, im lost at how to do this type of thing with C++ i can do other small things though. Can somebody help me? get me started? something?

thanks in advance,
Mapz_Maker
04-12-2007, 08:25 PM#2
Mapz_Maker
Might somebody help me? (provide me with includes for manipulating other windows, win32 api and things of that sort?)
04-12-2007, 08:34 PM#3
Magos
CIA?

Anyway, you mean the win32 function CreateWindow() or CreateWindowEx()?
04-12-2007, 08:43 PM#4
wyrmlord
Quote:
Originally Posted by Mapz_Maker
(provide me with includes for manipulating other windows, win32 api and things of that sort?)
You need windows.h to do win32 stuff. Besides that, I doubt you need anything more for manipulating windows that I can think of.
04-12-2007, 09:09 PM#5
Mapz_Maker
Quote:
Originally Posted by Mapz_Maker
(provide me with includes for manipulating other windows, win32 api and things of that sort?)

not my windows, other windows (notepad's window, AIM's window, IE's window, etc.)
04-12-2007, 09:09 PM#6
Alevice
You may need to learn a little bit of raw win32's api.

Code:
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>

int func() {
 HWND runningprogram=FindWindow(NULL, "Window Title");
 HWND control= CreateWindowEx(      
    DWORD dwExStyle,
    LPCTSTR lpClassName,
    LPCTSTR lpWindowName,
    DWORD dwStyle,
    int x,
    int y,
    int nWidth,
    int nHeight,
    HWND hWndParent, //<-- set it to runningprogram.
    HMENU hMenu,
    HINSTANCE hInstance,
    LPVOID lpParam
);

}

http://msdn.microsoft.com/library/de...eatewindow.asp
http://msdn.microsoft.com/library/de...findwindow.asp
04-12-2007, 09:10 PM#7
Mapz_Maker
Alevice, thank you, that is a lot closer to what i needed than wyrmlord or Magos said. Additional help is always welcome (and rep...)
04-12-2007, 09:13 PM#8
Alevice
If you need help with win32 window/control programming check this site: http://www.foosyerdoos.fsnet.co.uk/
04-12-2007, 09:32 PM#9
Mapz_Maker
thanks, you have been very helpful. (edit: it won't let me give more rep to you right now...)
04-12-2007, 09:34 PM#10
Alevice
I'm not concerned about rep. I just like to help.
04-12-2007, 09:50 PM#11
Mapz_Maker
I know, but it is always good 'courtesy' to give rep to those who help you (since that is all that i can give you, it does not cost me anything, it 'helps', and since you have not asked for help, i cannot give it. etc.)
04-12-2007, 10:01 PM#12
Alevice
Quote:
Originally Posted by Mapz_Maker
I know, but it is always good 'courtesy' to give rep to those who help you

I thought the trend was to verbally thank people :P
04-12-2007, 10:02 PM#13
Mapz_Maker
What is wrong? The compiler is giving me trouble...
The code:
Code:
// This is the main DLL file.
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
#include "stdafx.h"
#include "Control Inserter.h"

static void Main()
{
	public static bool MoveControltoWindow() {
    HWND runningprogram=FindWindow(NULL, "Window Title");
    HWND control= CreateWindowEx(      
    DWORD dwExStyle,
    LPCTSTR lpClassName,
    LPCTSTR lpWindowName,
    DWORD dwStyle,
    int x,
    int y,
    int nWidth,
    int nHeight,
    HWND hWndParent, //<-- set it to runningprogram.
    HMENU hMenu,
    HINSTANCE hInstance,
    LPVOID lpParam
	);
	}
}
The Errors:
Code:
Error	1	error C2143: syntax error : missing ';' before 'public'	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	11
Error	2	error C2143: syntax error : missing ';' before '{'	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	11
Error	3	error C2065: 'HWND' : undeclared identifier	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	12
Error	4	error C2146: syntax error : missing ';' before identifier 'runningprogram'	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	12
Error	5	error C2065: 'runningprogram' : undeclared identifier	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	12
Error	6	error C2065: 'NULL' : undeclared identifier	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	12
Error	7	error C3861: 'FindWindow': identifier not found	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	12
Error	8	error C2146: syntax error : missing ';' before identifier 'control'	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	13
Error	9	error C2065: 'control' : undeclared identifier	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	13
Error	10	error C2065: 'DWORD' : undeclared identifier	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	14
Error	11	error C2146: syntax error : missing ')' before identifier 'dwExStyle'	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	14
Error	12	error C2059: syntax error : ')'	c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2005\Projects\Control Inserter\Control Inserter\Control Inserter.cpp	26
04-12-2007, 10:06 PM#14
Alevice
It wasn't really a full-fledged example, just a couple of functions (the second just being a prototype plastered syntactically incorrect) to show you where to start. You really need to know some of the basics of win32 before attemtping to make it work.

What compiler are you using, by the way?

EDIT: Judging by the errors, you are using VS2005, and you are using something akin to Java's syntax, whta's up with that?
04-12-2007, 11:39 PM#15
Mapz_Maker
syntax? i just changed the func decleration to a C# decleration, i couldn't remember how to do it in C++ at the moment. C# is very powerful and awesome but, it can't do what i want so i needed to use C++. How should i have stated it?

And, could you post the corrected version?