Api :: SetWindowLong(hWnd, GWL_WNDPROC, Twiny::WndProc); probleme:(

JackosKing Messages postés 168 Date d'inscription mardi 31 décembre 2002 Statut Membre Dernière intervention 21 avril 2005 - 26 juin 2003 à 17:33
JackosKing Messages postés 168 Date d'inscription mardi 31 décembre 2002 Statut Membre Dernière intervention 21 avril 2005 - 26 juin 2003 à 22:36
Voilà je voulais utilisé cette fonction comme on me l'avait conseillé, mais j'ai une erreure:

E:\TinyShell\Twiny.cpp(56) : error C2664: 'SetWindowLongA' : cannot convert parameter 3 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'long'
        Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast


avec:
long Twiny::WndProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)

help:(

JackosKing For EvEr

6 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
26 juin 2003 à 19:13
fais une recherche "sous classement" et tu tomberas sur une de mes sources qui sous classe un EDIT, va idem pour nimporte quelle type de fenetre.
BruNews, ciao...
0
JackosKing Messages postés 168 Date d'inscription mardi 31 décembre 2002 Statut Membre Dernière intervention 21 avril 2005
26 juin 2003 à 20:14
j'ai regarer ton exemple et j'ai recopié:
SetWindowLong(hWnd, GWL_WNDPROC, (long) Twiny::WndProc);
}

LRESULT CALLBACK Twiny::WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if ( message == WM_MOUSEMOVE )
{
PostQuitMessage(0);
return 0;
}

return DefWindowProc(hwnd, message, wParam, lParam);
}
et j'ai toujours la meme erreur:(
JackosKing For EvEr
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
26 juin 2003 à 20:22
Et c'est quoi deja ton erreur ?
BruNews, ciao...
0
JackosKing Messages postés 168 Date d'inscription mardi 31 décembre 2002 Statut Membre Dernière intervention 21 avril 2005
26 juin 2003 à 21:48
bon alors la source:

#include "stdafx.h"
#include "Twiny.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

#define WS_EX_LAYERED 0x00080000
#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002

Twiny::Twiny()
{

}

Twiny::~Twiny()
{

}

Twiny::CreatTwiny( char *pStrIniFile, HINSTANCE hInstance )
{
char IniPath[MAX_PATH];
char PlugPath[MAX_PATH];
GetCurrentDirectory( MAX_PATH, IniPath);

sprintf( PlugPath, "%s\\Datas\\%s.ini", IniPath, pStrIniFile);

#define EXTRACT_NBR( VAR ) GetPrivateProfileString("TWINY",""#VAR""," ",IniPath,MAX_PATH,PlugPath ); VAR = atoi(IniPath);
EXTRACT_NBR( X )
EXTRACT_NBR( Y )
EXTRACT_NBR( Width ) 
EXTRACT_NBR( Height )
#undef EXTRACT_NBR

hWnd = CreateWindowEx(	WS_EX_TOPMOST ,"MyWndClassEx"," ", CW_USEDEFAULT | WS_VISIBLE,
X,
Y,
Width,
Height, 
NULL,
NULL,
hInstance,
NULL);
SetWindowLong(hWnd, GWL_WNDPROC, (long) Twiny::WndProc);
}

LRESULT CALLBACK Twiny::WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if ( message == WM_MOUSEMOVE )
{
PostQuitMessage(0);
return 0;
}

return DefWindowProc(hwnd, message, wParam, lParam);
}

BOOL Twiny::MakeAlpha(HWND hwnd,BYTE alpha)
{
/*	SLWA_FUNC MySetLayeredWindowAttributes;
HMODULE hUser32 = GetModuleHandle("USER32.DLL");
if (!hUser32) return FALSE;
MySetLayeredWindowAttributes = (SLWA_FUNC)GetProcAddress(hUser32,"SetLayeredWindowAttributes");
if (MySetLayeredWindowAttributes)
{
MySetLayeredWindowAttributes(hwnd,NULL,alpha,LWA_ALPHA|LWA_COLORKEY);
return TRUE;
} */
return FALSE;
}


l'erreur:
E:\TinyShell\Twiny.cpp(56) : error C2440: 'type cast' : cannot convert from 'long (__stdcall Twiny::*)(struct HWND__ *,unsigned int,unsigned int,long)' to 'long'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast

JackosKing For EvEr
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
26 juin 2003 à 21:56
je crois que doit etre declare 'static' si fonction de classe pour un callback. Pas certain car je ne suis pas tres classe comme mec alors faut voir.
BruNews, ciao...
0
JackosKing Messages postés 168 Date d'inscription mardi 31 décembre 2002 Statut Membre Dernière intervention 21 avril 2005
26 juin 2003 à 22:36
ca m'a l'air de fonctionner :p
encore une fois thx:)
JackosKing For EvEr
0
Rejoignez-nous