Message de rapport:
 

Re: Champ menu d'une fenêtre

Sujet: Re: Champ menu d'une fenêtre
par Anonyme sur 30/6/2006 18:43:43

J'ai du mal à comprendre l'avantage qu'il y a créer des classes pour encapsuler des appels de l'API.

Voici comment faire en pure SDK.

//Dans la partie Déclarations globales de la fenêtre principale écrire
gnPrevproc is int

//Dans la partie Initialisation de la fenêtre principale écrire
// On subclasse la fenêtre principale pour pouvoir prendre la main sur WinDev.
gnPrevproc = SetWindowLong(gnhMain, GWL_WNDPROC, &WndProc)

//Dans la partie Fermeture de la fenêtre principale écrire
IF gnPrevproc THEN
   SetWindowLong(gnhMain, GWL_WNDPROC, gnPrevproc)
   gnPrevproc = 0
END

//Dans la partie Procédures locales de la fenêtre principale créer la fonction callback
FUNCTION WndProc(nhWnd is int, nMsg is int, nwParam is int, nlParam is int)
nRet is int
SWITCH nMsg
    CASE WM_MENUCOMMAND
    // Ecrire votre code ici
    CASE etc.
END
IF gnPrevproc THEN
   nRet = CallWindowProc(gnPrevproc, nhWnd, nMsg, nwParam, nlParam)
END
RESULT nRet

//-------------------------------------------
// Encapsulation de l'API "SetWindowLong"
FUNCTION SetWindowLong(nHandle is int, nIndex is int, nNewValue is int)
nRet is int = API("USER32", "SetWindowLongA", nHandle, nIndex, nNewValue)		
RESULT nRet

//-------------------------------------------
// Encapsulation de l'API "CallWindowProc"
FUNCTION CallWindowProc(nPrevProc is int, nHandle is int, nMsg is int, nwParam is int, nlParam is int)
nRet is int = API("USER32", "CallWindowProcA", nPrevProc, nHandle, nMsg, nwParam, nlParam)
RESULT nRet


Connexion
Menu
Chercher WDForge
Chercher Web
Partenaires
Visualiser tous les Partenaires...
WinDev, WebDev, WinDev Mobile et HyperFile sont des marques déposées par PCSoft. |  Voter |  Legal |  Contact |   XOOPS 2.0.13.2