|
Thanks
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
Is there a way to set a console application to open "full screen" when it is built as a final release? I know you can right click and go to "properties" to set the window to full screen, but can I enter some code to permanently do the same thing? Thanks.
VC++ 6.0
|
|
|
|
|
Use GetConsoleDisplayMode to see if the window needs to change and if it does send Alt-Enter to the consol window. Thats the only way I know. I havent seen any API that changes the fullscreen mode of a consol window.
Magnus
|
|
|
|
|
I'm working on the program below. It sorts numbers fine, but it only lets me sort ONE number. I want to have the option to either choose to enter another search or quit. I'm not sure how to setup the program to repeat the search. How can I accomplish this. Thanks, Dave.
<br />
<br />
#include <iostream><br />
#include <cstdio><br />
using namespace std;<br />
<br />
int main()<br />
<br />
{<br />
int x;<br />
int i;<br />
char str[80];<br />
char Info [] [300] = <br />
{<br />
"3030-02-000-5287" , "Here is the information for this number."<br />
"3030-03-000-0029" , "Here is the information for this number."<br />
};<br />
<br />
cout<<"Please enter a number:\n";<br />
cin>>str;<br />
<br />
for(i=0; i < 4; i += 2)<br />
if(!strcmp(str, Info[i]))<br />
{<br />
cout<<"Information:"<<Info[i+1]<<"\n";<br />
break;<br />
}<br />
<br />
{if(i == 4)<br />
cout<<"Number not found.\n";<br />
}<br />
<br />
{cout<<"\nWould you like to check another?\n";<br />
cout<<"Enter 1 for yes, 0 for no.\n";<br />
cin>>x>>"\n";}<br />
<br />
<br />
return 0;<br />
}<br />
<br />
-----------------------------------------------------
VC++ 6.0
|
|
|
|
|
int main()
{
int x;
int i;
char str[80];
bool isfinished=false;
char Info [] [300] =
{
"3030-02-000-5287" , "Here is the information for this number."
"3030-03-000-0029" , "Here is the information for this number."
};
while(isfinished==false)
{
cout<<"Please enter a number:\n";
cin>>str;
for(i=0; i < 4; i += 2)
if(!strcmp(str, Info[i]))
{
cout<<"Information:"<<Info[i+1]<<"\n";
break;
}
if(i == 4)
{
cout<<"Number not found.\n";
}
x=-1;
cout<<"\nWould you like to check another?\n";
while(x!=0 && x!=1)
{
cout<<"Enter 1 for yes, 0 for no.\n";
cin>>x>>"\n";
}
if (x==0)
isfinished=true;
}
return 0;
}
~RaGE();
|
|
|
|
|
I get the following message Rage when I run the code:
Compiling...
rage.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\Rage NSN Lookup\rage.cpp(22) : error C2065: 'strcmp' : undeclared identifier
Error executing cl.exe.
-----------------------------------------------------
it's this line below:
if(!strcmp(str, Info[i]))
-----------------------------------------------------
Rage NSN Lookup.exe - 1 error(s), 0 warning(s)
VC++ 6.0
|
|
|
|
|
Look in the MSDN for strcmp you will see that it says it requires a header file, from memory string.h . Also you will see what, if any, extra libraries it requires.
Simply press F1 when you cursor is over the strcmp text in your file.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
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
|
|
|
|