|
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
|
|
|
|
|
Hi there,
I output 2 data structs into one file. I need to swap the data in that file. Would I need to create a new struct that is comprised of those two structs, store it, swap the bytes and dump it back into the file? The file contains chars and unsigned shorts.
Thanks!
|
|
|
|
|
I'm envisioning something like:
struct s1;
struct s2;
read data into s1;
read data into s2;
write data from s2;
write data from s1; Is that anywhere close?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yes, write data from s1 and s2 to someFileName. Swap the data in that file and write to PCMCIA card. To extract from the card, we need to reverse the order.
|
|
|
|
|
Hi!
I was wondering if you could help me with something. I have to write code on serial communication for my computing class, and I was hoping you could take a look at it for me?
I can't figure out what the problem is. It's impossible to read data while the program is executed - there's no data in que then - but debugging it, it works fine ...?! I've also used WaitCommEvent, but it works like crap, too. It seems that actually no data arrives, just why?. Isn't it possible to see how much data is present and read exactly that amount? The interface hooked up at Rs232 works faultlessly. What else could cause such problems I'm confronted with?
I hope this and my English did make any sense to you
Awaiting your response,
Pit
Maybe someone wanna take a closer look at my code. Here it is:
(Please let me know if I've made any terrible errors!)
<br />
#include "Com_Handle.h"<br />
<br />
unsigned char CRC(void);<br />
<br />
<br />
Com_Port::Com_Port()<br />
{<br />
Init_ELM();<br />
}<br />
<br />
Com_Port::~Com_Port()<br />
{<br />
Close_Comport(DriverHandle);<br />
}<br />
<br />
<br />
HANDLE Com_Port::Open_Comport (DWORD Comport)<br />
{ <br />
switch (Comport) <br />
{<br />
case 1:<br />
strcpy (Com_Name, "COM1");<br />
break;<br />
case 2:<br />
strcpy (Com_Name, "COM2");<br />
break;<br />
case 3:<br />
strcpy (Com_Name, "COM3");<br />
break;<br />
case 4:<br />
strcpy (Com_Name, "COM4");<br />
break;<br />
default:<br />
return 0;<br />
}<br />
<br />
<br />
DriverHandle = CreateFile (Com_Name,<br />
GENERIC_READ | GENERIC_WRITE,<br />
0,<br />
NULL,<br />
OPEN_EXISTING,<br />
0,<br />
NULL);<br />
<br />
<br />
if (DriverHandle == INVALID_HANDLE_VALUE) <br />
{<br />
Get_Error();<br />
return (FALSE);<br />
}<br />
return DriverHandle;<br />
}<br />
<br />
<br />
int Com_Port :: Config_ComPort(HANDLE DriverHandle, DWORD BaudRate)<br />
{<br />
cout << "Configuring ELM ..." << endl;<br />
<br />
switch (BaudRate)<br />
{<br />
case 110:<br />
DCB_Baud_Rate = CBR_110;<br />
break; <br />
case 300:<br />
DCB_Baud_Rate = CBR_300;<br />
break; <br />
case 600:<br />
DCB_Baud_Rate = CBR_600;<br />
break; <br />
case 1200:<br />
DCB_Baud_Rate = CBR_1200;<br />
break; <br />
case 2400:<br />
DCB_Baud_Rate = CBR_2400;<br />
break; <br />
case 4800:<br />
DCB_Baud_Rate = CBR_4800;<br />
break; <br />
case 9600:<br />
DCB_Baud_Rate = CBR_9600;<br />
break; <br />
case 14400:<br />
DCB_Baud_Rate = CBR_14400;<br />
break; <br />
case 19200:<br />
DCB_Baud_Rate = CBR_19200;<br />
break;<br />
case 38400:<br />
DCB_Baud_Rate = CBR_38400;<br />
break; <br />
case 56000:<br />
DCB_Baud_Rate = CBR_56000;<br />
break; <br />
default:<br />
return 0;<br />
}<br />
<br />
<br />
<br />
if(!SetupComm (DriverHandle, 1024, 1024))<br />
Get_Error();<br />
<br />
<br />
if(!GetCommState (DriverHandle, &ELM_DCB))<br />
Get_Error();<br />
<br />
ELM_DCB.BaudRate = DCB_Baud_Rate;<br />
ELM_DCB.fParity = 0;<br />
ELM_DCB.fOutxCtsFlow = 0;<br />
ELM_DCB.fOutxDsrFlow = 0;<br />
ELM_DCB.fDtrControl = DTR_CONTROL_DISABLE;<br />
ELM_DCB.fDsrSensitivity = FALSE;<br />
ELM_DCB.fTXContinueOnXoff = 0;<br />
ELM_DCB.fOutX = 0;<br />
ELM_DCB.fInX = 0;<br />
ELM_DCB.fErrorChar = 0;<br />
ELM_DCB.fNull = 0;<br />
ELM_DCB.fRtsControl = RTS_CONTROL_DISABLE;<br />
ELM_DCB.fAbortOnError = 0;<br />
ELM_DCB.ByteSize = 8;<br />
ELM_DCB.Parity = NOPARITY;<br />
ELM_DCB.StopBits = ONESTOPBIT;<br />
<br />
if(!SetCommState (DriverHandle, &ELM_DCB))<br />
Get_Error();<br />
<br />
<br />
if(!SetCommMask (DriverHandle, EV_TXEMPTY))<br />
Get_Error();<br />
<br />
COMMTIMEOUTS sTo;<br />
<br />
if(GetCommTimeouts(DriverHandle, &sTo))<br />
{<br />
sTo.ReadIntervalTimeout = 100;<br />
sTo.ReadTotalTimeoutConstant = 100 ;<br />
sTo.ReadTotalTimeoutMultiplier = 100;<br />
sTo.WriteTotalTimeoutConstant = 0;<br />
sTo.WriteTotalTimeoutMultiplier = 0;<br />
}<br />
else<br />
{<br />
return (FALSE);<br />
}<br />
<br />
if(!(SetCommTimeouts(DriverHandle, &sTo)))<br />
{<br />
Get_Error();<br />
}<br />
return 0; <br />
}<br />
<br />
<br />
<br />
<br />
int Com_Port :: Close_Comport (HANDLE DriverHandle)<br />
{<br />
<br />
if ((DriverHandle == 0) || (DriverHandle == INVALID_HANDLE_VALUE))<br />
{<br />
return FALSE; <br />
}<br />
<br />
CloseHandle (DriverHandle);<br />
<br />
<br />
return TRUE;<br />
}<br />
<br />
<br />
int Com_Port :: Write_Comport (HANDLE DriverHandle, DWORD NumBytes, void *Buffer)<br />
{<br />
DWORD BytesWritten; <br />
BOOL status;<br />
<br />
if ((DriverHandle == 0) || (DriverHandle == INVALID_HANDLE_VALUE)) {<br />
return FALSE;<br />
} <br />
<br />
<br />
status = WriteFile (DriverHandle, Buffer, NumBytes, &BytesWritten, 0);<br />
<br />
<br />
return TRUE;<br />
}<br />
<br />
<br />
<br />
<br />
<br />
int Com_Port :: Read_Comport (HANDLE DriverHandle,<br />
DWORD *BytesRead,<br />
DWORD BufferSize,<br />
void *Buffer)<br />
{<br />
COMSTAT Our_Comstat;<br />
<br />
if ((DriverHandle == 0) || (DriverHandle == INVALID_HANDLE_VALUE)) {<br />
return (FALSE);<br />
} <br />
<br />
<br />
ClearCommError (DriverHandle, &Com_Errors, &Our_Comstat);<br />
<br />
<br />
<br />
cout << "QUE: " << Our_Comstat.cbInQue << endl;<br />
<br />
if (Our_Comstat.cbInQue > 0) <br />
{<br />
if (Our_Comstat.cbInQue > BufferSize)<br />
{<br />
BytesToRead = BufferSize;<br />
} <br />
else<br />
{<br />
BytesToRead = Our_Comstat.cbInQue;<br />
}<br />
<br />
<br />
if (!ReadFile (DriverHandle, Buffer, BytesToRead, BytesRead, NULL))<br />
{<br />
cout << "Read FAIL!\n";<br />
}<br />
}<br />
else<br />
{<br />
*BytesRead = 0;<br />
}<br />
return TRUE;<br />
}<br />
<br />
int Com_Port::Get_Error()<br />
{<br />
Com_Errors = GetLastError();
cout << "An error occured: " << GetLastError() << endl << endl;<br />
return 0;<br />
}<br />
<br />
unsigned int Com_Port::Port_No = 0;<br />
<br />
int Com_Port :: Init_ELM ()<br />
{ <br />
cout << "Searching ComPort, please wait. \n\n";<br />
do<br />
{ <br />
Port_No ++;<br />
DriverHandle = Open_Comport (Port_No);<br />
}<br />
while(!DriverHandle && Port_No != 5);<br />
if (!DriverHandle)<br />
{<br />
cout << "Unable to open port" << endl;<br />
return 0;<br />
}<br />
cout << "Connected on " << Com_Name << endl;<br />
Config_ComPort(DriverHandle, 9600);<br />
ComHandle = DriverHandle;
return 0;<br />
}<br />
<br />
<br />
unsigned char CRC(void)<br />
{<br />
unsigned char msg_buf[20], nBytes=0;<br />
<br />
unsigned char CRC_Reg=0xff;<br />
unsigned char poly,i,j;<br />
unsigned char Checksum=0;<br />
unsigned char *Byte_point, Bit_point;<br />
<br />
for (i=0, Byte_point=msg_buf; i<nBytes; i++, Byte_point++)<br />
{<br />
for (j=0, Bit_point=0x80 ; j<8; j++, Bit_point>>=1)<br />
{<br />
if (Bit_point & *Byte_point)<br />
{<br />
if (CRC_Reg & 0x80)<br />
poly=1;<br />
<br />
else<br />
poly=0x1C;<br />
<br />
CRC_Reg= ( (CRC_Reg << 1) | 1)^poly;<br />
}<br />
else<br />
{<br />
poly=0;<br />
<br />
if (CRC_Reg & 0x80)<br />
poly=0x1D;<br />
<br />
CRC_Reg= (CRC_Reg << 1)^poly;<br />
}<br />
}<br />
}<br />
return ~CRC_Reg;
}<br />
<br />
|
|
|
|
|
I was having a hellova time trying to trace this without formatting so I took the liberty to format it so I could take a look. I figured I'd repost the code with the formattng preserved so others who want to take a look and try to help you find the problem won't have to spend the 5 or 10 minutes needed to indent and such.
#include "Com_Handle.h"
unsigned char CRC(void);
Com_Port::Com_Port()
{
Init_ELM();
}
Com_Port::~Com_Port()
{
Close_Comport(DriverHandle);
}
HANDLE Com_Port::Open_Comport (DWORD Comport)
{
switch (Comport) {
case 1:
strcpy (Com_Name, "COM1");
break;
case 2:
strcpy (Com_Name, "COM2");
break;
case 3:
strcpy (Com_Name, "COM3");
break;
case 4:
strcpy (Com_Name, "COM4");
break;
default:
return 0;
}
DriverHandle=CreateFile(Com_Name,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if (DriverHandle==INVALID_HANDLE_VALUE) {
Get_Error();
return (FALSE);
}
return DriverHandle;
}
int Com_Port::Config_ComPort(HANDLE DriverHandle,DWORD BaudRate) {
cout << "Configuring ELM ..." << endl;
switch (BaudRate) {
case 110:
DCB_Baud_Rate=CBR_110;
break;
case 300:
DCB_Baud_Rate=CBR_300;
break;
case 600:
DCB_Baud_Rate=CBR_600;
break;
case 1200:
DCB_Baud_Rate=CBR_1200;
break;
case 2400:
DCB_Baud_Rate=CBR_2400;
break;
case 4800:
DCB_Baud_Rate=CBR_4800;
break;
case 9600:
DCB_Baud_Rate=CBR_9600;
break;
case 14400:
DCB_Baud_Rate=CBR_14400;
break;
case 19200:
DCB_Baud_Rate=CBR_19200;
break;
case 38400:
DCB_Baud_Rate=CBR_38400;
break;
case 56000:
DCB_Baud_Rate=CBR_56000;
break;
default:
return 0;
}
if(!SetupComm (DriverHandle, 1024, 1024))
Get_Error();
if(!GetCommState (DriverHandle, &ELM_DCB))
Get_Error();
ELM_DCB.BaudRate = DCB_Baud_Rate;
ELM_DCB.fParity = 0;
ELM_DCB.fOutxCtsFlow = 0;
ELM_DCB.fOutxDsrFlow = 0;
ELM_DCB.fDtrControl = DTR_CONTROL_DISABLE;
ELM_DCB.fDsrSensitivity = FALSE;
ELM_DCB.fTXContinueOnXoff = 0;
ELM_DCB.fOutX = 0;
ELM_DCB.fInX = 0;
ELM_DCB.fErrorChar = 0;
ELM_DCB.fNull = 0;
ELM_DCB.fRtsControl = RTS_CONTROL_DISABLE;
ELM_DCB.fAbortOnError = 0;
ELM_DCB.ByteSize = 8;
ELM_DCB.Parity = NOPARITY;
ELM_DCB.StopBits = ONESTOPBIT;
if(!SetCommState (DriverHandle, &ELM_DCB))
Get_Error();
if(!SetCommMask (DriverHandle, EV_TXEMPTY))
Get_Error();
COMMTIMEOUTS sTo;
if(GetCommTimeouts(DriverHandle,&sTo)) {
sTo.ReadIntervalTimeout = 100;
sTo.ReadTotalTimeoutConstant = 100 ;
sTo.ReadTotalTimeoutMultiplier = 100;
sTo.WriteTotalTimeoutConstant = 0;
sTo.WriteTotalTimeoutMultiplier = 0;
} else {
return (FALSE);
}
if(!(SetCommTimeouts(DriverHandle, &sTo))) {
Get_Error();
}
return 0;
}
int Com_Port::Close_Comport(HANDLE DriverHandle)
{
if ((DriverHandle==0)||(DriverHandle==INVALID_HANDLE_VALUE)) {
return FALSE;
}
CloseHandle (DriverHandle);
return TRUE;
}
int Com_Port::Write_Comport (HANDLE DriverHandle, DWORD NumBytes, void *Buffer)
{
DWORD BytesWritten;
BOOL status;
if ((DriverHandle==0) || (DriverHandle==INVALID_HANDLE_VALUE)) {
return FALSE;
}
status=WriteFile(DriverHandle,Buffer,NumBytes,&BytesWritten,0);
return TRUE;
}
int Com_Port::Read_Comport(HANDLE DriverHandle,DWORD * BytesRead,DWORD BufferSize,void *Buffer)
{
COMSTAT Our_Comstat;
if ((DriverHandle==0) || (DriverHandle==INVALID_HANDLE_VALUE)) {
return (FALSE);
}
ClearCommError (DriverHandle,&Com_Errors,&Our_Comstat);
cout << "QUE: " << Our_Comstat.cbInQue << endl;
if (Our_Comstat.cbInQue > 0) {
if (Our_Comstat.cbInQue > BufferSize) {
BytesToRead=BufferSize;
} else {
BytesToRead=Our_Comstat.cbInQue;
}
if (!ReadFile (DriverHandle, Buffer, BytesToRead, BytesRead, NULL)) {
cout << "Read FAIL!\n";
}
} else {
*BytesRead = 0;
}
return TRUE;
}
int Com_Port::Get_Error()
{
Com_Errors= etLastError();
cout << "An error occured: " << GetLastError() << endl << endl;
return 0;
}
unsigned int Com_Port::Port_No=0;
int Com_Port::Init_ELM () {
cout << "Searching ComPort, please wait. \n\n";
do {
Port_No ++;
DriverHandle = Open_Comport (Port_No);
} while(!DriverHandle && Port_No != 5);
if (!DriverHandle) {
cout << "Unable to open port" << endl;
return 0;
}
cout << "Connected on " << Com_Name << endl;
Config_ComPort(DriverHandle, 9600);
ComHandle=DriverHandle;
return 0;
}
unsigned char CRC(void)
{
unsigned char msg_buf[20], nBytes=0;
unsigned char CRC_Reg=0xff;
unsigned char poly,i,j;
unsigned char Checksum=0;
unsigned char *Byte_point, Bit_point;
for (i=0,Byte_point=msg_buf;i {
for (j=0, Bit_point=0x80 ; j<8; j++, Bit_point>>=1) {
if (Bit_point & *Byte_point) {
if (CRC_Reg & 0x80)
poly=1;
else
poly=0x1C;
CRC_Reg= ( (CRC_Reg << 1) | 1)^poly;
} else {
poly=0;
if (CRC_Reg & 0x80)
poly=0x1D;
CRC_Reg= (CRC_Reg << 1)^poly;
}
}
}
return ~CRC_Reg;
}
|
|
|
|
|
Hello,
I have an activeX control project which contains several controls. When you start an AtiveX control project you are allowed to select how many components syou want the project to contain.
What happens now that I want to add more components to this project?Can't seem to find any information elsewhere.
Thanks!
|
|
|
|
|
hello,
I didn't know where to ask so I hope you can help me ...
I want to develop nokia series 60 applications ... and I am using sdk 2.1 with visual studio .net and I don't see a class wizard ... I have downloaded sdk 1.2 who has a wizard for visual studio 6 and it seems that class wizard is still not implemented... or I didn't figure out how to use it ... plizzz can anyone help me ... what IDE should I use to develop this kind of applications or ... what should I do to make visual studio 6 / visual studio.net class wizard works !
thank you ...
|
|
|
|
|
codewarrior with the symbian simulator for nokias...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi There,
Does anyone know of a third party software that allows me to do simple graphics (lines, polylines, text, etc...) in an EMF format and be able to drap/drop and edit the images?
I've looked into LEAD Technologies and MetaDraw but they're not exactly what I'm looking for. Ther former doesn't support editing and MetaDraw is a VB OCX, mainly with VB documentation.
Any help in this matter is greatly appreciated.
Thank,
A.
|
|
|
|
|
Hi All
if have a variable
m_e_date = COleDateTime::GetCurrentTime();
which equals the current time,
how do i get it so that its the current time plus 2 hours
similar to DATEADD in SQL
or how do i increase the current time by two hours
so 14:00 would be 16:00
hope that makes sense
|
|
|
|
|
Take a look at COleDateTimeSpan. This should do the trick
|
|
|
|
|
How about:
COleDateTime now = COleDateTime::GetCurrentTime();
now += COleDateTimeSpan(2, 0, 0, 0);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
COleDateTime now = COleDateTime::GetCurrentTime();now += COleDateTimeSpan(2, 0, 0, 0);
superb
|
|
|
|
|
IS there any way check if file exist without attempting to open the file? Just by looking at directory structure?
I am using MFC and trying to open 2 files simultaneously. Each one can't be open unless the other exist.
|
|
|
|
|
PathFileExists() will be helpfull to u.
-prakash
|
|
|
|
|
i use
BOOL bExist;
CFileFind finder;
bExist=finder.FindFile(strDirPath);
if(bExist)
{
finder.FindNextFile();
if(!finder.IsDirectory())
bExist=FALSE;
}
finder.Close();
|
|
|
|
|
There's always the good old CRT function access()....
onwards and upwards...
|
|
|
|
|
See here for a discussion on this common subject.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
hey David,
do you know your links still don't work ???
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
No I didn't. Thanks.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hey all,
I've got a configuration app to write, and I think that the tree/grid control that the VS.NET 2003 IDE uses for Class properties would be a perfect fit. Anyone know what it's called, or where I can find it?
Here's what I'm talking about:
http://www.saxmanwebs.com/upload/./userfiles/Zin/PropControl.jpg
Thanks!
-Mike Zinni
"Don't take life too seriously, you'll never make it out alive"
- Van Wilder
|
|
|
|
|
I have made a class and I need to use it's subroutines in another class. How do I make these references?
|
|
|
|
|
derive the class from the class that you want to use the member functions is one option.
Depending on the design you can also create an instance of that class whose member function you want to use.
-prakash
|
|
|
|
|
Anonymous wrote:
How do I make these references?
By using either of the member-selection expressions: . or ->
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|