|
Add
#include <string.h> at the top of the file.
But this means the code you've posted did not compile, then ...
~RaGE();
|
|
|
|
|
I forgot the "string.h" header include. I got your code to compile with no errors or warnings, BUT when I run the program, it hangs up with a warning that it couldn't write to memory. This occurs when I enter a "1" to continue searching. Any ideas?
Thanks much, Dave.
VC++ 6.0
|
|
|
|
|
I would expect the way you handle the Info table to be the problem (I have actually never seen a table be initialised und used that way, but that's probably because I'm a poor programmer ). Try and debug the program to see where it asserts.
~RaGE();
|
|
|
|
|
Thanks Rage, that while statement worked great...
The problem was that I needed to remove the "\n" from at the end of the cin<
|
|
|
|
|
Hi!
I created a standard MFC form view based program. And I want to control its scroll bar in my program.
In my program, I need the scroll bar's scrolling range from 0 to 299000.
In response of the message:
OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
I find the nPos value range is 0 to 32xxx, which I belive is a 16 bit data type. (each time, when I scroll it right and it increses beyond 32xxx, it suddenly turns to 0 and starts again from 0).
Now, the problem comes: I use a int type counter to indicate where the scroll bar is and update its position (also update some other variables in my program). But since the nPos only has limited range, each time when I scroll greater than 32xxx, the OnHScroll returns me a wrong number and the scroll bar will not working properly.
Any idea of this?
Thanks.
|
|
|
|
|
To use 32bit scroll values you need to use GetScrollInfo() and SetScrollInfo().
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Thanks a lot.
Just for those also interested it,
I get it done like this:
This method of extracting 32-bit scroll box positions works only in those scroll messages that are sent to a window when the user grabs the thumb and drags it. It is not possible to obtain 32-bit scroll box position in cases of programmatically sent SB_THUMBTRACK and SB_THUMBPOSITION scroll messages. First, the 32-bit information cannot be packed into the WPARAM of the messages because only the High Word contains the scroll position. Second, the nTrackPos member of the SCROLLINFO structure maintained for scroll bars cannot be set programmatically. Any calls to SetScrollInfo to set the immediate scroll positions are ignored by the operating system.
Sample Code
void CMyWnd::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if(nSBCode == SB_THUMBTRACK || nSBCode == SB_THUMBPOSITION)
{
// First determine if the user scrolled a scroll bar control
// on the window or scrolled the window itself
HWND hWndScroll;
if ( pScrollBar == NULL )
hWndScroll = m_hWnd;
else
hWndScroll = pScrollBar->m_hWnd;
SCROLLINFO info;
info.cbSize = sizeof(SCROLLINFO);
info.fMask = SIF_TRACKPOS;
::GetScrollInfo(hWndScroll, SB_HORZ, &info);
nPos = info.nTrackPos;
}
//......
//......
}
I found this from here:
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q152/2/52.asp&NoWebContent=1
|
|
|
|
|
Hi..
Just wondering if there is a installation software like installshield which can automatically install an device driver(with inf file).
i have written a program which calls an SetupCopyOEMInf function from DDK. It works fine with win2000 and winxp but not with win98 and me..
thanks...
|
|
|
|
|
do u really think this is your most important thing??
if your driver is not a WDM one, then you will have to write a second version only for 98/me.
|
|
|
|
|
Hi All,
Attached is a simple c++ code that is to be, after compilation, called from MATLAB. When the line "afxbeginthread" is removed every thing is ok. When the line is re-placed the code compile but does not execute. Any suggestions?
Regards
Sam, Melbourne
#include "c:\temp\stdafx.h"
#include "c:\temp\mex.h"
/********************************************************************/
UINT THREADD1(LPVOID pParam)
{
printf(" %10.1f\n", 5.5);
return 0;
}
/*********************************************************************/void init_rt_pars ( void )
{
printf(" %10.1f\n", 3.3);
}
/*********************************************************************//* The GateWay Routine */
/* /********************************************************************/
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray*prhs[] )
{
/*************************************************************/ init_rt_pars();
AfxBeginThread(THREADD1,NULL);
init_rt_pars();
/*************************************************************/
return;
}
|
|
|
|
|
Try CreateThread and _beginThread!
A. Riazi
|
|
|
|
|
Hi A. Riazi,
Many thanks for your reponse.
I have tried CreateThread with no success.
I have also eliminated MATLAB now (ie the function that initiates the thread is main() not mexFunction) and the problem is still there. Any further suggestions?
Regards,
Sam
|
|
|
|
|
Try replacing:
<br />
AfxBeginThread(THREADD1,NULL);<br />
with:
<br />
AfxBeginThread(THREADD1,NULL,0,0,0,NULL);<br />
|
|
|
|
|
Why would this:
fwrite(dataPtr,sizeof(unsigned char),(sizeof(unsigned char)*datalength),filePtr);
ALWAYS return 0 byte written
I can open the file ok using
filePtr = fopen (DataFile,"wb");
but whenever I try to write the data down it fails.
Anyideas?
Thanks!
|
|
|
|
|
are you sure your dataPtr is not NULL ?
(or 0 - whichever your prefer )
|
|
|
|
|
lol
I just checked that and it seems my data pointer is not pointing to the right place. LOL. fix that and then try again.
Thanks. I might be back.
|
|
|
|
|
ok pointers are all correct now, data is where I need it to be. But still, no data being written when calling the fwrite.
|
|
|
|
|
Did the file open succeed? If you look at the data buffer in the debugger is it what you expect? What does errno tell you? Why aren't you checking what fopen() and fwrite() return.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Firstly, your code should be like this:
fwrite(dataPtr, sizeof(unsigned char), datalength, filePtr);
It does not make any difference in case of a char, but if you use integers for example, your code will try to write 4x4xdatalength = 16xdatalength bytes of data, instead of writing 4xdatalength bytes.
Anyway, apart from that be sure to check the datalength. Check out whether it is 0 or not.
If it still does not work, add the following line after writing to the file:
fflush (filePtr);
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
<nobr>They say I'm lazy but it takes all my time
|
|
|
|
|
Ok,
I did finally find it. Turned out that my global datasize number was being clobbered all the time, aka ending in a data size of 0 to be written.
Thanks for all of your help! I REALLY appreciate it!
Woo HOO!!
Dan
|
|
|
|
|
Dear Forum,
Ok, this is really starting to bug me. Anybody have any idea why the 'TableName' is not being added to the string 'str', even though the 'TableName' seems to be valid as the watch window shows the correct value and the TRACE call does manage to successfully out put it?
for (std::vector<DFields *>::iterator it = pConfig->Samples.begin(); it != pConfig->Samples.end(); ++it)
{
CString str = _T("");
if (pConfig->IncludeComputer)
{
str += (*it)->ComputerName;
str += _T(" : ");
}
if (pConfig->IncludeTable)
{
TRACE("*%s*\n", (*it)->TableName);
str += (*it)->TableName;
str += _T(" : ");
}
str += (*it)->SampleName;
m_ListSelected.AddString(str);
}
After this function, 'str' is (sans quotes): "Barn 1 Feed : : Total Daily Feed"
and the TRACE output is: "*743 Daily*".
str should be: "Barn 1 Feed : 743 Daily : Total Daily Feed"
I have tried to do a rebuild all, exit dev studio and then rebuild all, even rebooted my computer. But still no luck. All I know is that I will probably see what I am doing wrong as soon as I hit the submit button
[edit]
ComputerName, Tablename, and SampleName are all CStrings.
[/edit]
Signed
Confused in abby
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
I don't have a clue,
but have you tried casting the TableName to f.e. (char *) or something alike..?
I wouldn't be amazed if it was some sort of type-confusion..
|
|
|
|
|
hmmm. That worked. wierd
Thanks a lot .
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Its because your mixing crappy old MFC CString and lovely new STL, you naughty boy you.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Hello i was told to look here for something that would convert a VC++ 7.10 Project to a VC++ 7.0 project can anyone help me ???
|
|
|
|