|
I would do this in the following order:
Forget about the UI to start with, amd simply practice drawing text into the View at a hard
coded place. This will let you learn about CFont, pDC->SelectObject, pDC->SetTextBkMode,
pDC->TextOut / pDC->DrawText.
Then make a toolbar so you can switch between graphic modes (pen, line, text, etc).
Create Command Handlers for them, so the button / menu for the current tool is inset / ticked.
Then in your mouse button handler, pop up a box to input some text. Add the text and its
coordinates (from the mouse position) to a list of some kind in your CMyDocument. Redraw
the screen with the new text.
Relax in a warm glow of achievement. Have a or to taste.
Iain.
|
|
|
|
|
Class CA
{
protected:
CA();
private:
int a;
int b;
CRect c;
}
CA::CA():c(0,0,100,100){
a=0;
b=0;
}
What's the difference between both of the initialization ways in function "CA()"?
Thank you in advance!
|
|
|
|
|
The initialisation list you used with you variable c is executed before the constructor is even called - it is part of the allocation of the instance.
But on the other hand, you have to be careful: The initialisation list does not care about the order in which you placed them - the are executed in the order the variables are allocated (declared). After all, initialisation lists are part of the allocation.
OTOH, a and b are of undefined value before they get assigned a value. (and they need an assignment operator able to cope whith the values they got assigned - initialisation lists do not.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thank you!
|
|
|
|
|
Is there a way to increase the font size in a console application? A larger text would be nicer to read.
Thanks, Dave
VC++ 6.0
|
|
|
|
|
Simple answer, no.
The user can change the console settings themselves, (font, number of columns, rows etc), but the
console takes what is given. If a spiffy UI is what you want, console is not the way to go...
I *believe* you can stream out escape characters to make parts of your text bold, but I'm not too
sure.
Iain.
|
|
|
|
|
I guess that you could configure your console font size in windows if i am not mistaken.
|
|
|
|
|
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
|
|
|
|