|
char dbBuff[INFO_BUFFER_SIZE]={0};
char HoldDBBuff[INFO_BUFFER_SIZE]={0};
DWORD dwBytesWrittenTrans;
HANDLE HND=CreateFile(FileName.c_str(),GENERIC_READ, NULL, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
BOOL read=ReadFile(HND,dbBuff,sizeof(dbBuff),&dwBytesWrittenTrans,NULL);
int dbCount=0;
int dbHoldCount=0;
bool proceed=false;
while (dbBuff[dbCount]!=0)
{
if (dbBuff[dbCount]=='*'||proceed)
{
strcpy((char*)HoldDBBuff[dbHoldCount], (const char*)dbBuff[dbCount]);
dbHoldCount++;
proceed=true;
}
dbCount++;
}
As soon as I try and do a strcpy, the IDE brings up the assembly code and a error occurs.
Can someone please help ??
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
|
Programm3r wrote: Stupid ....
When I first read this reply, I didn't know it was to yourself - I thought it was kinda
harsh!
I'm not sure about the above line, but, as Michael mentioned, those casts in the strcpy
call are suspicious (bad!)
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Programm3r wrote: strcpy((char*)HoldDBBuff[dbHoldCount], (const char*)dbBuff[dbCount]);
Why are you casting characters to character pointers?
|
|
|
|
|
I think I see what you're trying to do, but you need to take the address of dbBuff[dbCount] before casting it to a (const char*):
strcpy((char*)HoldDBBuff[dbHoldCount], (const char*)&dbBuff[dbCount]);
(Notice the & I added.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
What about the destination address?
Maybe
strcpy((char*)&HoldDBBuff[dbHoldCount], (const char*)&dbBuff[dbCount]);
??
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Yep, that one needs it, too. I guess I looked at it too quickly and thought that he was copying part of the source into the beginning of the destination.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
There is no need for those casts. Incorrect casts mask errors, and this was the case in the OP's original code. He probably threw in casts to "fix the compiler errors" and ended up with non-functional code.
|
|
|
|
|
Those are the OP's original casts - not mine. I know they aren't needed, but his main problem (as you eluded to in your first post) was that the buffer had already been dereferenced.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
When using Visual C++ 6.0 and 7.1 to create a message handler for WM_NCPAINT, the wizard places a comment in there...
void CSomeView::OnNcPaint()
{
// TODO: Add your message handler code here
// Do not call CScrollView::OnNcPaint() for painting messages
}
Because I don't want to draw the scroll bar myself, I call CScrollView::OnNcPaint() but I feel like I'm beaking some major programming rule but I do not know what that rule is. I've not been able to detect any problems with doing this except of course some redundant drawing that might occur elsewhere in the non-client area that causes a teeny tiny amount of flicker where my drawing code differs from that of he default.
Does anyone know why the "Do not call CScrollView::OnNcPaint() for painting messages" warning gets placed in this handler and what is it intended to prevent?
|
|
|
|
|
Because in general, if you handle WM_NCPAINT , you're going to repaint the whole NC area for skinning or some similar purpose. The comment is just an advisory that if you do call the base class function, you'll get the standard NC area, which is not usually what you want because you're handling WM_NCPAINT . The world won't end if you call it, but you will end up with double the painting work and possibly flicker.
|
|
|
|
|
Thanks for the assistance.
|
|
|
|
|
Hi all,
I would like to know whether this is a healthy way to terminate another process?
HANDLE pid=win.winftp_findPid("application.exe");
BOOL p=TerminateProcess(pid, STILL_ACTIVE);
Many Thanks.
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
I would try to send a WM_CLOSE message first... and if the application doesn't respond, then kill
|
|
|
|
|
toxcct wrote: then kill
lol ... thanks for the info toxcct.
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
Thanks toxcct.
It works....
HWND hWnd=FindWindow(NULL, "Window Name");
SendMessage(hWnd, WM_CLOSE , NULL, NULL);
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
Welcome
|
|
|
|
|
Actually no, TerminateProcess() should be the last thing you try. You'd better hope the app wasn't in the middle or writing to some crucial data file when you killed it.
|
|
|
|
|
My english is very poor. I'm sorry.
Maybe I can not express my meaning clearly, so, Please look at the codes below.
<br />
...............<br />
SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTProc.........<br />
...............<br />
<br />
LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)<br />
{<br />
if(nCode == HCBT_CREATEWND)<br />
{<br />
HWND hWnd = (HWND) wParam;<br />
LPCBT_CREATEWND pcb = (LPCBT_CREATEWND) lParam;<br />
TCHAR szClassName[255] = _T("\0");<br />
<br />
GetClassName( hWnd, szClassName,sizeof(szClassName) / sizeof(TCHAR) );<br />
<br />
if(! lstrcmp(szClassName, _T("Button")))<br />
{<br />
CButtonST * pNewButton = new CButtonST;<br />
if( pNewButton )<br />
pNewButton->SubclassWindow( hWnd );<br />
}<br />
}<br />
return CallNextHook( nCode, wParam, lParam);<br />
}
These codes works well in other windows, dialogbox, but they can not work in messageBox, Why????
-- modified at 1:29 Sunday 22nd April, 2007
|
|
|
|
|
sdhexu wrote:
These codes works well in other windows, dialogbox, but they can not work in messageBox, Why????
are you able to hook the messagebox!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Hi
All
I want to change font of ToolTip control in My project.So anybody have some hint or code to change font of Tooltip control.
Thanks in Advance
Atul
|
|
|
|
|
|
Hello,
can i use virtual lists to show data in grid?
regards
termal
|
|
|
|
|
yes.
what data ?
what grid ?
|
|
|
|
|
Hello Maximilien,
i have two kind of lists, one as CGridCtrl and one as CListCtrl.
I know now how to use virtual lists in CListCtrl, i read data from file, line by line and show them
in my CListCtrl:
my solution now is:
read all in an array
and then fill CListCtrl form this array
but i need it in this order(and here i have problems):
read line
show line
read line
show line
because every time when i want to add items to list i recive an exception(owner data problem)
Example for CGridCtrl(MFC Grid by Chris Maunder) i dont have yet!
regards
termal
|
|
|
|