Click here to Skip to main content
15,910,471 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalexcel automation with very hidden sheet Pin
pnpfriend9-Dec-04 10:38
pnpfriend9-Dec-04 10:38 
QuestionWhat is best Exe 2 Exe protocol? Pin
Malcolm Smart9-Dec-04 10:34
Malcolm Smart9-Dec-04 10:34 
AnswerRe: What is best Exe 2 Exe protocol? Pin
Alex Korchemniy9-Dec-04 11:05
Alex Korchemniy9-Dec-04 11:05 
AnswerRe: What is best Exe 2 Exe protocol? Pin
Renjith Ramachandran9-Dec-04 19:13
Renjith Ramachandran9-Dec-04 19:13 
AnswerRe: What is best Exe 2 Exe protocol? Pin
Henry miller10-Dec-04 6:31
Henry miller10-Dec-04 6:31 
GeneralVariable width fonts and GetTextExtent in CEdit Pin
bob169729-Dec-04 8:47
bob169729-Dec-04 8:47 
GeneralRe: Variable width fonts and GetTextExtent in CEdit Pin
bob169729-Dec-04 11:01
bob169729-Dec-04 11:01 
GeneralHTML Help window Message handling Pin
Member 15760289-Dec-04 8:44
Member 15760289-Dec-04 8:44 
Hi,
I am trying to create a Windows Application that uses the HTMLHelp API to launch a help file.(.CHM file). But am not able to associate the windows created by HtmlHelp(..) command to the message queue. It's not entering into the WindowsProcedure associated with that Application though I followed the HtmlHelp documentation. Please find the .cpp file attached. I feel am going wrong somewhere. Please help me out.
Very urgent help needed.
thanks in advance,

//////
Code: (windows application project type); include htmlhelp.lib
/////

/////////////////////////////////////////////////////////////////////////
// helpsysfinalwinapp.cpp : Defines the entry point for the application.
/////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"
#include "stdio.h"
#include "windows.h"
#include "Htmlhelp.h"
#include "conio.h"
#include "stdlib.h"

#define MAX_LOADSTRING 100
#define ID_NOTIFICATION 4242

// Global Variables:
HINSTANCE hInst;
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];
HWND HwndDlg;
DWORD dwCookie = NULL;

// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;

bool bvRetVal;
HACCEL hAccelTable;
nCmdShow=SW_MAXIMIZE;
HtmlHelp(NULL,NULL,HH_INITIALIZE,(DWORD)&dwCookie) ;
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_HELPSYSFINALWINAPP, szWindowClass, MAX_LOADSTRING);

MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
// msg.hwnd=HwndDlg;
//hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_HELPSYSFINALWINAPP);
while (GetMessage (&msg, NULL, 0, 0)) //Retrieve a message from the
{

//calling thread's message queue
if (!HtmlHelp (
NULL,
NULL,
HH_PRETRANSLATEMESSAGE,
(unsigned long)&msg))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}

}
HtmlHelp(NULL, NULL, HH_UNINITIALIZE, (DWORD)dwCookie) ;
return msg.wParam;


}


////////////////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
///////////////////////////////////////////////////////////////////////////////////////

ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_HELPSYSFINALWINAPP);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_HELPSYSFINALWINAPP;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}

///////////////////////////////////////////////////////////////////////////
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
////////////////////////////////////////////////////////////////////////////


BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{

LPCSTR pszFile = "C:\\Langref.chm";
LPCSTR pszWin = "C:\\Langref.chm>test";

// get the wintype
HH_WINTYPE m_hhWinType;

hInst = hInstance; // Store instance handle in our global variable
HwndDlg=GetDesktopWindow();
ZeroMemory(&m_hhWinType, sizeof(HH_WINTYPE));
//HtmlHelp(HwndDlg, pszWin, HH_GET_WIN_TYPE, (DWORD) &pwt);
// copy contents of returned wintype
//m_hhWinTyp = *pwt;
m_hhWinType.hwndCaller=HwndDlg;
m_hhWinType.fsWinProperties = HHWIN_PROP_TRI_PANE |
HHWIN_PROP_AUTO_SYNC|HHWIN_PROP_TRACKING |HHWIN_PROP_ONTOP|HHWIN_PROP_NODEF_STYLES;
m_hhWinType.fsToolBarFlags = HHWIN_BUTTON_BACK |
HHWIN_BUTTON_HOME | HHWIN_BUTTON_FORWARD |
HHWIN_BUTTON_EXPAND;
// Indicate which fields in structure are valid.
m_hhWinType.fsValidMembers = HHWIN_PARAM_STYLES |
HHWIN_PARAM_PROPERTIES | HHWIN_PARAM_RECT |
HHWIN_PARAM_TB_FLAGS | HHWIN_PARAM_NAV_WIDTH |
HHWIN_PARAM_SHOWSTATE | HHWIN_PARAM_TABPOS |
HHWIN_PARAM_CUR_TAB|HHWIN_PROP_POST_QUIT;
m_hhWinType.iNavWidth = 175;

// Initial display state:
// NOTE: fsValidMembers - HHWIN_PARAM_SHOWSTATE must be set.
m_hhWinType.nShowState = SW_RESTORE;

// TOC should be activated.
// NOTE: fsValidMembers - HHWIN PARAM_CUR_TAB must be set.
m_hhWinType.curNavType = HHWIN_NAVTYPE_TOC;

// Tabs on top.
// NOTE: fsValidMembers - HHWIN_PARAM_TABPOS must be set.
m_hhWinType.tabpos = HHWIN_NAVTAB_TOP;
m_hhWinType.pszCaption= "TEST";

// set notification id
m_hhWinType.idNotify = ID_NOTIFICATION;
// rememeber to force the correct size
m_hhWinType.pszType = "test";
m_hhWinType.hwndHelp =HwndDlg;
// now send the new window type
HtmlHelp(HwndDlg, pszFile, HH_SET_WIN_TYPE, (DWORD) &m_hhWinType);
HtmlHelp(HwndDlg,"C:\\Langref.chm>test",HH_HELP_CONTEXT,5223);
if (HwndDlg==NULL) {
printf("Failed to open the Help file\n");
};

if (!HwndDlg)
{
return FALSE;
}
//ShowWindow(hWnd, nCmdShow);
//UpdateWindow(hWnd);
return TRUE;
}

///////////////////////////////////////////////////////////////////
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//////////////////////////////////////////////////////////////////


LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

/////////////////////////////////////////////////////////////////////////
// Mesage handler for about box.
/////////////////////////////////////////////////////////////////////////

LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}



////////////////////////////////////////////////////////////////////////
// helpwinapp.cpp : Defines the entry point for the application.
///////////////////////////////////////////////////////////////////////


naag
Generalswap bytes in a file Pin
Anonymous9-Dec-04 8:09
Anonymous9-Dec-04 8:09 
GeneralRe: swap bytes in a file Pin
David Crow9-Dec-04 10:24
David Crow9-Dec-04 10:24 
GeneralRe: swap bytes in a file Pin
Anonymous9-Dec-04 10:29
Anonymous9-Dec-04 10:29 
GeneralSerial Communication ... problems! Pin
PPatrickFFM9-Dec-04 5:48
PPatrickFFM9-Dec-04 5:48 
GeneralRe: Serial Communication ... problems! Pin
bob169729-Dec-04 9:43
bob169729-Dec-04 9:43 
GeneralAdding controls to ActiveX project Pin
greekgoddj9-Dec-04 5:06
greekgoddj9-Dec-04 5:06 
GeneralSymbian OS Pin
Anonymous9-Dec-04 5:00
Anonymous9-Dec-04 5:00 
GeneralRe: Symbian OS Pin
toxcct9-Dec-04 21:50
toxcct9-Dec-04 21:50 
GeneralGraphics in C++ Pin
al_in_the_city9-Dec-04 4:49
al_in_the_city9-Dec-04 4:49 
GeneralDate Add Pin
si_699-Dec-04 4:26
si_699-Dec-04 4:26 
GeneralRe: Date Add Pin
Cedric Moonen9-Dec-04 4:36
Cedric Moonen9-Dec-04 4:36 
GeneralRe: Date Add Pin
David Crow9-Dec-04 5:40
David Crow9-Dec-04 5:40 
GeneralRe: Date Add Pin
si_6912-Dec-04 12:02
si_6912-Dec-04 12:02 
GeneralCheck if file exist Pin
Anonymous9-Dec-04 4:15
Anonymous9-Dec-04 4:15 
GeneralRe: Check if file exist Pin
Prakash Nadar9-Dec-04 4:29
Prakash Nadar9-Dec-04 4:29 
GeneralRe: Check if file exist Pin
si_699-Dec-04 4:35
si_699-Dec-04 4:35 
GeneralRe: Check if file exist Pin
basementman9-Dec-04 5:43
basementman9-Dec-04 5:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.