Click here to Skip to main content
15,884,473 members
Articles / Desktop Programming / Win32

JavaScript function access from plain C++: An example

Rate me:
Please Sign up or sign in to vote.
4.31/5 (8 votes)
24 Aug 2008CPOL1 min read 46.2K   1.1K   29  
How to execute JavaScript functions with parameters from C++ code.
///-////////////////////////////////////////////////////////////////////////////////////////////////
///     Autor:  David Elias Flores Escalante
///     Company: TeleTracking SAC
///     URL: http://teletrackingsac.dnsalias.net
///     Date:   24/08/2008
///     File name: dWindow.cpp
///     License: Free, but autor and company must be mentioned.
///-////////////////////////////////////////////////////////////////////////////////////////////////

#include "dWindow.h"
#include "dFont.h"


HFONT EzCreateFont (HDC hdc,TCHAR * szFaceName, int iDeciPtHeight,
                    int iDeciPtWidth, int iAttributes, BOOL fLogRes);

dWindow::dWindow()
{
    lstrcpy(Titulo,"");
}

BOOL dWindow::SetTitulo(LPCSTR szTitulo)
{
    return(SetWindowText(hWnd,szTitulo));

}


LONG dWindow::GetId()
{
    return (GetWindowLong(hWnd,GWL_ID));
}

HWND dWindow::GetHwnd()
{
    return(hWnd);
}

HWND dWindow::GetPadre()
{
    return(hParent);
}

int dWindow::GetHeight()
{
    GetWindowRect(hWnd,&rect);
    //GetClientRect(hWnd,&rect);
    return(rect.bottom-rect.top);
}

int dWindow::GetWidth()
{
    GetWindowRect(hWnd,&rect);
    return(rect.right-rect.left);
}

HMENU dWindow::GetPopupMenu()
{
    return (hPopUpMenu);
}

HINSTANCE dWindow::GetInstance()
{
    return ((HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE));
}

void dWindow::SetWindowFont(TCHAR* FontName,int size)
{
    static HFONT hFont;
    static HDC hdc;

    hdc=GetDC(hWnd);

    hFont = EzCreateFont ( hdc,FontName, size,0,0,TRUE) ;
    SendMessage(hWnd,WM_SETFONT,(WPARAM) hFont,MAKELPARAM(TRUE, 0));
}


void dWindow::SetBKColor(COLORREF newColor)
{
    SetClassLong(hWnd,GCL_HBRBACKGROUND,(LONG)CreateSolidBrush(newColor));
}


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer TeleTracking SAC
Peru Peru
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions