|
Could it be a handshaking problem? This is very common so make sure flow control is turned off since it has to be working at both ends.
The tigress is here
|
|
|
|
|
Thank you very much for your reply. I double check the flow control setting.
I am using "PJ Naughter" Serial class. like:
CSerialPort::GetDefaultConfig(1, config);
CSerialPort port;
port.Open(1, 9600, CSerialPort::NoParity, 8, CSerialPort::OneStopBit, CSerialPort::NoFlowControl);
HANDLE hPort = port.Detach();
port.Attach(hPort);
DWORD dwModemStatus;
port.GetModemStatus(dwModemStatus);
DCB dcb;
port.GetState(dcb);
dcb.BaudRate = 9600;
port.SetState(dcb);
DWORD dwErrors;
port.ClearError(dwErrors);
port.SetBreak();
port.ClearBreak();
COMSTAT stat;
port.GetStatus(stat);
COMMTIMEOUTS timeouts;
port.GetTimeouts(timeouts);
port.Setup(10000, 10000);
port.GetConfig(config);
config.dcb.BaudRate = 9600;
port.SetConfig(config);
port.Set0WriteTimeout();
port.Set0ReadTimeout();
char sBuf[] = "This should appear on the serial port";
port.Write(sBuf, strlen(sBuf)); -------------------------> Stop here
What kind of reason cause this problem?
Thank you very much!
|
|
|
|
|
I assuem you have tried iusing Hyperterminal, To make sure the comms link is working oK? e.g. that he cable is OK etc.
"An education isn't how much you have committed to memory, or even how much you know. It's being able to differentiate between what you do know and what you don't." - Anatole France
|
|
|
|
|
I have a sample application that is registering for the notification of the file-create . I am using SHChangeNotifyRegister API to get the notifcation . Since my appln is to be supported in 98/me i haved used this . But when i copy around 50 files .. .. I am getting notification of only 20 files .. .I have attached the code for your reference
Header file
#define WM_USER_MEDIACHANGED WM_USER+88
// For the Shell notifier, to indicate the type of events for which to receive
// notifications.
#define SHCNF_ACCEPT_INTERRUPTS 0x0001
#define SHCNF_ACCEPT_NON_INTERRUPTS 0x0002
#define SHCNRF_RecursiveInterrupt 0x1000
typedef struct {
DWORD dwItem1; // dwItem1 contains previous PIDL or name of the folder.
DWORD dwItem2; // dwItem2 contains the new PIDL or name of the folder.
} SHNOTIFYSTRUCT;
// Memeber Functions.
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
.cpp file
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MSG Msg;
HWND hWnd;
WNDCLASSEX WndClsEx;
ULONG l_ulSHChangeNotifyRegister;
const char *ClsName = "BasicApp";
const char *WndName = "A Simple Window";
// Create the application window
WndClsEx.cbSize = sizeof(WNDCLASSEX);
WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
WndClsEx.lpfnWndProc = WndProcedure;
WndClsEx.cbClsExtra = 0;
WndClsEx.cbWndExtra = 0;
WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClsEx.lpszMenuName = NULL;
WndClsEx.lpszClassName = ClsName;
WndClsEx.hInstance = hInstance;
WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
//BY_HANDLE_FILE_INFORMATION handle;
// Register the application
RegisterClassEx(&WndClsEx);
hWnd = CreateWindow(ClsName,
WndName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if( !hWnd ) // If the window was not created,
return 0; // stop the application
// Display the window in hidden mode.
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
// Get the folder locations of the folders to be monitored using the CSIDL_XXXX values and
// store it in the identifiers list.
LPITEMIDLIST ppidl = NULL;
if(SHGetSpecialFolderLocation(hWnd, CSIDL_DRIVES , &ppidl) == S_OK)
{
SHChangeNotifyEntry shCNE;
shCNE.pidl = ppidl;
shCNE.fRecursive = TRUE;
// Returns a positive integer registration identifier (ID).
// Returns zero if out of memory or in response to invalid parameters.
l_ulSHChangeNotifyRegister = SHChangeNotifyRegister(hWnd,// Hwnd to receive notification
SHCNF_ACCEPT_INTERRUPTS | SHCNF_ACCEPT_NON_INTERRUPTS|SHCNRF_RecursiveInterrupt ,
// Events of interest - use
SHCNE_CREATE,
// Notification message to be sent when the event has occured
WM_USER_MEDIACHANGED,
// Number of entries in the pfsne array should always be 1
1,
// Array of SHChangeNotifyEntry structures that
// contain the notifications.
&shCNE);
}
else
{
// Log error in retrieving folder info of system.
}
while( GetMessage(&Msg, NULL, 0, 0) )
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
// Window call back function
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_DESTROY:
arr.Format("%d",nCount);
MessageBox(NULL,arr,"Message",MB_OK);
PostQuitMessage(WM_QUIT);
break;
case WM_USER_MEDIACHANGED:
switch(lParam)
{ case SHCNE_CREATE: //File create
if (TRUE == SHGetPathFromIDList((struct _ITEMIDLIST *)shNotifyStr->dwItem1, sourcePath))
{
nCount++; }
break;
default:
break;
}
default:
// Process the left-over messages
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
|
|
|
|
|
For performance reasons, multiple notifications may be combined into a single notification.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
thanks . You mean to say for performance reason Windows OS itself is giving only few notifications ? . Is there anyway to overcome this problem .
|
|
|
|
|
ragavan wrote:
You mean to say for performance reason Windows OS itself is giving only few notifications ?
That's exactly what I'm saying.
ragavan wrote:
Is there anyway to overcome this problem .
What problem?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I had asked yesterday if there was a way to look at all the files in a directory and I was directed to CFileFind, but for some reason, as I use .FindNextFile() and .GetFileName(), it's skipping like 4 files every time! Any help?
Danny
|
|
|
|
|
|
Actually, I have to retract that question. It does seem to search all the files, just in a different order than I would have expected. It does seem, though, that when I try to open the file just after I found it that the file doesn't open.
Here's the code I'm working with...
CFileFind finder;
BOOL bWorking = finder.FindFile(searchPath);
while (bWorking)
{
bWorking = finder.FindNextFile();
fileList[counter] = (LPCTSTR) finder.GetFileName();
path = (LPCTSTR) finder.GetFilePath();
examine.open(path, ios::in | ios::nocreate | ios::noreplace);
.
.
.
}
(fileList is an array of CStrings, path is a CString, and examine is an fstream.)
Is the finder possibly interfering with opening the file?
Danny
|
|
|
|
|
bugDanny wrote:
fileList[counter] = (LPCTSTR) finder.GetFileName();
path = (LPCTSTR) finder.GetFilePath();
While not related to the actual problem, the two casts are unnecessary.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
The order you see is dependant upon the underlying file system. For NTFS, you will generally see the files in alphabetical order by name. For FAT32, it's in 'directory' order, which is generally the order in which the files were added to the directory.
bugDanny wrote:
Is the finder possibly interfering with opening the file?
Doubtful. Try debugging your examine.open function with a hand-entered, known good file path.
Software Zen: delete this;
|
|
|
|
|
Dear Community,
I have a question about integration of context sensitiv help for dialogs in a vc++ developed application. I use a window with several tabs and like to provide help for the tabdialogs. Every tab obtained a contextid and the contextid is compiled into the chm-helpfile. I display the contextid of the called tabdialog after pressing F1 in a message window.
Only the first tab starts the help and displayes the context id, when I hit F1 oder use the "What is" function. The helpfilecall of all other tabs, if they are active, dos not work and no contextid is displayed. Can anyone tell me what's the reason for?
Thanks in advance for help.
Heyerdahl
|
|
|
|
|
I'm writing a C++ DLL to speed up (run time over 1 hour) an excel macro. I read arrays in the macro, pass them to the DLL as SAFEARRAYs, identify the memory location, assign it to a new C++ array. I read some of the arrays and write to others. Then the excel macro reads the arrays and writes the results to a spreadsheet.
An early version of the program ran OK (50,000 loops through the arrays) -- after some early problems -- and the results were correct (I verified them manually in excel). The run time was reduced by a factor of over 10 !!!.
Then I expanded the program and now it freezes up -- never at the same place but always on the same type of command and always a memory access violation, either assigning the pointer to the C++ array or reading from/writing to the array.
The code looks like this:
In excel macro:
Code:
Option Explicit
Option Base 0
Public CF() As Double, IssuerCorrel() As Double, CRN() As Double, TransitionIndex() As Integer, TransCutoff(0 To 6, 0 To 7) As Double, IssuerEndRatingCode() As Integer
Declare Sub Cholesky Lib “C:\CreditRisk\CreditSim.dll” (IssuerCorrel() As Double, CF() As Double, ByVal IssuerCount As Integer)
Sub ScenarioGenerator()
Application.Calculation = xlCalculationManual: Application.ScreenUpdating = False: Application.EnableEvents = False
Dim IssuerCount As Integer,
Read in some data from spreadsheets
Dim IssuerCorrel(IssuerCount, IssuerCount) as Single; CF(IssuerCount, IssuerCount) as Single
Read more data from spreadsheets
Call Cholesky(IssuerCorrel(), CF(), ByVal IssuerCount)
Write some output data to spreadsheets
End Sub
In C++:
Code:
#include "stdafx.h"
#include <windows.h>
#include <oleauto.h>
#include "CreditSim.h"
#include "Oaidl.h"
#include <stdlib.h>
#include <math.h>
#include <time.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
void __declspec (dllexport) __stdcall Cholesky(
SAFEARRAY **IssuerCorrel, SAFEARRAY **CF, short IssuerCount)
{
double L = 0.999999;
short n = IssuerCount;
long i = 0;long j = 0; long k = 0;
srand( (unsigned) time( NULL ) );
HRESULT SafeArrayLock( SAFEARRAY **IssuerCorrel );
HRESULT SafeArrayLock( SAFEARRAY **CF );
// Create new arrays that point to the Safearray data locations
double* CFc;
CFc = (double*)(*CF)->pvData;
CFc[0]= *CFc; Program fails here.
double* IssuerCorrelc;
IssuerCorrelc = (double*)(*IssuerCorrel)->pvData;
IssuerCorrelc [0] =*IssuerCorrelc; Program fails here.
CFc[n*(n-1)+n-1] = IssuerCorrelc[n*(n-1)+n-1];
for (j = n-2; j>=0; j--)
{
CFc[n*j + j] = IssuerCorrelc[n*j + j];
for (k = n-1; k>j; k--)
{
CFc[n*j + k] = IssuerCorrelc[n*j + k] * L;
for (i = k + 1; i
|
|
|
|
|
When you call function Cholesky you should have at more than zero element in the array IssuerCorrel and CF. Try to check that before calling because when array is 0 you have failure.
|
|
|
|
|
Hi there,
I am creating Edit Box at runtime with CEdit class
and I have to pass there Edit Box Styles
but it is displying the Edit Box with flat property
can anybody tell me how we can creat 3D look like Edit Box
Bye
Regards
IndianOcean
|
|
|
|
|
WS_EX_CLIENTEDGE
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I have already used this property but
it did not come in to required look.
do u have any other preoperty for 3D look?
Thanks & Regards
Indian Ocean
|
|
|
|
|
WS_EX_CLIENTEDGE is the one for 3D look. Are you sure that it is not being removed somehow?
Run Spy++ and use the window finder to select the control, then look under the Styles tab - extended styles list to see if WS_EX_CLIENTEDGE is listed.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I have checked the styles
From Spy and u are right it is not listed in the styles..
Some how it is being removed or like that
i m using these properties
WS_CHILD | WS_BORDER | WS_VISIBLE | ES_LEFT |WS_EX_CLIENTEDGE ,
if can tell me something.........
thanks & regards
Indian Ocean
|
|
|
|
|
WS_EX_CLIENTEDGE is an extended style, not a regular style, so it can not be used with the other styles you listed.
Use the CreateEx function to create your edit control
MyEdit.CreateEx(WS_EX_CLIENTEDGE,
_T("EDIT"),
NULL,
WS_CHILD | WS_BORDER | WS_VISIBLE | ES_LEFT,
&Rect,
pParentWnd,
nID,
NULL);
See CWnd::CreateEx in MSDN for more info.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
hello friends i need to develop a vc++ program which can add new item in menu of excel and can open a form to insert text in selected cells
|
|
|
|
|
Ok, so what exactly do you need help with? Have you looked at MSDN article Q178749 to see how to use Excel automation?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
hello friends i need to develop a vc++ program which can add new item in menu of excel and can oen a form to insert text in selected cells
|
|
|
|
|
Hello Friends
How can a MFC application determine if it was invoked in response to one of its registered file being double clicked?
regards,
Kuldeep
|
|
|
|
|