SourceCode auf PureBasic lauffähig machen

Fragen zu allen anderen Programmiersprachen.
Benutzeravatar
Leonhard
Beiträge: 602
Registriert: 01.03.2006 21:25

SourceCode auf PureBasic lauffähig machen

Beitrag von Leonhard »

Gibt es jemand, der diesen SourceCode http://www.codeproject.com/treectrl/ctreelistctrl.asp so übersetzen kann, das er in PureBasic funktioniert bzw. eine DLL, die mit PureBasic lauffähig ist?

Ich kam darauf, da mehrere im Forum nach einer verknüpfung vom TreeGadget und dem ListViewGadget fragten.

Ich und eine mänge PureBasic Usern währen wohl dem PureBasic-User sehr zum Dank verpflichtet, der der es schaft, dies auf PureBasic lauffähig zu machen.
Benutzeravatar
Leonhard
Beiträge: 602
Registriert: 01.03.2006 21:25

Beitrag von Leonhard »

Ich bin beim übersetzen des Codes. Komme leider an dieser Stelle nicht mehr weiter. Kann mir jemand helfen.

Code: Alles auswählen

typedef BOOL (WINAPI *lpfnUpdateLayeredWindow)(	HWND hWnd, HDC hdcDst, POINT *pptDst, 
												SIZE *psize,HDC hdcSrc, POINT *pptSrc, 
												COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags );
typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes)( HWND hwnd, COLORREF crKey, BYTE xAlpha, DWORD dwFlags );



static lpfnUpdateLayeredWindow g_lpfnUpdateLayeredWindow = NULL;
static lpfnSetLayeredWindowAttributes g_lpfnSetLayeredWindowAttributes = NULL;

BOOL InitLayeredWindows()
{
	if( g_lpfnUpdateLayeredWindow == NULL || g_lpfnSetLayeredWindowAttributes == NULL )
	{
		HMODULE hUser32 = GetModuleHandle(_T("USER32.DLL"));

		g_lpfnUpdateLayeredWindow =	(lpfnUpdateLayeredWindow)GetProcAddress( hUser32, _T("UpdateLayeredWindow") );
		g_lpfnSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress( hUser32, _T("SetLayeredWindowAttributes") );

		if( g_lpfnUpdateLayeredWindow == NULL || g_lpfnSetLayeredWindowAttributes == NULL )
			return FALSE;
	}

	return TRUE;
}
Benutzeravatar
edel
Beiträge: 3667
Registriert: 28.07.2005 12:39
Computerausstattung: GameBoy
Kontaktdaten:

Beitrag von edel »

Code: Alles auswählen

  Prototype lpfnUpdateLayeredWindow(hwnd,hdcDst,*pptDst.POINT,*psize.SIZE,hdcSrc,*pptSrc.POINT,crKey,*pblend,dwFlags )
  Prototype lpfnSetLayeredWindowAttributes(hwnd,crKey,xAlpha.b,dwFlags)
  
  Global g_lpfnUpdateLayeredWindow.lpfnUpdateLayeredWindow
  Global g_lpfnSetLayeredWindowAttributes.lpfnSetLayeredWindowAttributes
  
  Procedure InitLayeredWindows() 
    
    If( g_lpfnUpdateLayeredWindow = #Null And g_lpfnSetLayeredWindowAttributes = #Null) 
      
      Protected hUser32 = GetModuleHandle_("USER32.DLL")
      
      g_lpfnUpdateLayeredWindow         = GetProcAddress_(hUser32,"UpdateLayeredWindow")
      g_lpfnSetLayeredWindowAttributes  = GetProcAddress_(hUser32,"SetLayeredWindowAttributes")
      
      If ( g_lpfnUpdateLayeredWindow = #Null And g_lpfnSetLayeredWindowAttributes = #Null) 
        ProcedureReturn #False
      EndIf
      
      ProcedureReturn #True
      
    EndIf 
  EndProcedure

Wenn du allerdings daran schon scheiterst, bist du denn sicher dass du
das packst ?
Benutzeravatar
Leonhard
Beiträge: 602
Registriert: 01.03.2006 21:25

Beitrag von Leonhard »

edel hat geschrieben:Wenn du allerdings daran schon scheiterst, bist du denn sicher dass du
das packst ?
Wenn es kein anderer tut, mach ich es halt, da ich das benötige.

Ich brauche noch eine Hilfe (hoffendlich die letzte): Wie kann ich folgenden Klasse in PureBasic übersetzen? (am wichtigsten ist mir die abarbeitung des WindowCallbacks)

Code: Alles auswählen

class CTreeListCtrl;

class CTreeListTipCtrl : public CWnd
{
// Construction
public:
	CTreeListTipCtrl();
	virtual ~CTreeListTipCtrl();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CTreeListTipCtrl)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	//}}AFX_VIRTUAL

	// Generated message map functions
protected:
	//{{AFX_MSG(CTreeListTipCtrl)
	afx_msg void OnPaint();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CTreeListTipCtrl::CTreeListTipCtrl()
{
	// construction
	WNDCLASS wndcls;
	HINSTANCE hInst = AfxGetInstanceHandle();

	if( ::GetClassInfo( hInst, TREELISTTIPCTRL_CLASSNAME, &wndcls ) == FALSE )
	{
		wndcls.style =  CS_DBLCLKS ;
		wndcls.lpfnWndProc		= ::DefWindowProc;
		wndcls.cbClsExtra		= 0;
		wndcls.cbWndExtra		= 0;
		wndcls.hInstance		= hInst;
		wndcls.hIcon			= NULL;
		wndcls.hCursor			= LoadCursor(hInst, IDC_ARROW);
		wndcls.hbrBackground	= (HBRUSH)(COLOR_INFOBK+1);
		wndcls.lpszMenuName		= NULL;
		wndcls.lpszClassName	= TREELISTTIPCTRL_CLASSNAME;

		if( !AfxRegisterClass(&wndcls) )
			AfxThrowResourceException();
	}

	// for layer windows
	m_bLayeredWindows = InitLayeredWindows();
}

BEGIN_MESSAGE_MAP(CTreeListTipCtrl, CWnd)
	//{{AFX_MSG_MAP(CTreeListTipCtrl)
	ON_WM_PAINT()
	ON_WM_TIMER()
	ON_WM_MOUSEACTIVATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
Antworten