|
i'm not sure i understand well.
what functions so you use ? SetWindowText() and GetWindowText() are the one to use to transfer datas between controls and CString.
moreover, you should be careful on printing a CString into a CEdit control. first, it must be using the multi-line option. secondly, each '\n' on the CString must be replaced by "\r\n" in the CEdit otherwise you won't see any new lines in the edit control...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
You hit the nail on the head!!
However, not all of my Edit control variables are of the CString type: I have some Edit variables of INT type. Initially, I have used the MFC DDX/DDV methods to swap data from the dialog to variables and back. But, after retrieving data from a file, I still cannot get the data into the INT Edit variables though I can load data into the CString Edit variables better using the methods provided and the ReadString method of CStdioFile.
Any suggestions, directions, help on loading the INT Edit variables? And, THANK YOU for the prior methods, which worked like a charm for the CString Edit variables!!;)
WohooWahoo
|
|
|
|
|
hum, just an idea like that... did you well used UpdateData(TRUE) to store the contents of the controls toward the associated variables, and UpdateDate(FALSE) for the reverse operation ?
another thing :
wohoowahoo wrote:
not all of my Edit control variables are of the CString type
Of course !! they are CEdit ones, all of them !!!
In fact, when you think you make an edit of type CString or UINT or anything else, you only associate (through DDX and DoDataExchange()) a member variable of type CString or UINT with the actual CEdit object that is currently used in the dialog.
wohoowahoo wrote:
after retrieving data from a file, I still cannot get the data into the INT Edit variables
hum, tell me, how are supposed to be the datas into this EditBox ?
you can try something else if you still cannot find a way :
CEdit* pEdit = ((CEdit*)GetDlgItem(IDC_MYEDIT));
CString strEdit;
pEdit->GetWindowText(strEdit);
UINT uiEditVal;
::sscanf(strEdit, "%u", &uiEditVal);
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
For some reasons, I want to use splitter window in CWnd, not in CFrameWnd or CMDIChildWnd. I try to use CSplitterWnd, but it doesn't work.
Thanks.
|
|
|
|
|
HI,
I am new to mFC programming .
I ahve been trying to create an application where a figure is drawn with a default colour and then user can select from a range of colours in the menu.
The problem wid my application is that it is not accepting the new colour when i check it. It is supposed to draw the new figure in a different colour when I select a colour from the menu.
I might be going wrong somewhr.
could anyone tell me how to go about doing what I am trying to implement.
Thanks
U get wht u Give
|
|
|
|
|
Are you drawing the figure in the OnDraw() or OnPaint() method? Where are you storing the new color value? Is it being used?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I am using the ondraw function. I have a variable called color in the doc class and a function which returns the current colour. I ma calling this function in the ondraw function to get the colour. Below is the code of ondraw function and the doc class..
void CFiguresdiView::OnDraw(CDC* pDC)<br />
{<br />
CFiguresdiDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
COLORREF m_nColor = pDoc->GetCurrentColor();<br />
<br />
CBrush brush (m_nColor);<br />
int x1 = 100;<br />
int y1 = 100;<br />
int x2 = 300;<br />
int y2 = 400;<br />
CRect rect (x1, y1, x2, y2);<br />
pDC->FillRect (rect, &brush);<br />
}
In the document class i ahve the following code.
<br />
COLORREF CFiguresdiDoc::GetCurrentColor()<br />
{<br />
return m_nColor;<br />
}<br />
<br />
void CFiguresdiDoc::OnColorsRed() <br />
{ <br />
m_nColor=RGB (255,0,0);<br />
}<br />
<br />
void CFiguresdiDoc::OnColorsGreen() <br />
{<br />
m_nColor = RGB(0,255,0);
}<br />
<br />
void CFiguresdiDoc::OnUpdateColorsGreen(CCmdUI* pCmdUI) <br />
{<br />
pCmdUI->SetCheck (m_nColor == RGB (0, 255, 0));<br />
}<br />
<br />
<br />
void CFiguresdiDoc::OnUpdateColorsRed(CCmdUI* pCmdUI) <br />
{<br />
pCmdUI->SetCheck (m_nColor == RGB (0, 255, 255));
<br />
}
m_nColor is of type COLORREF.
i AHVE SET THE DEFAULT COLOR AS RED . It is set in the onNew Document function. IF i try doing the same thing on OnButtonDown event of mouse in the client area the color does change.
I am not able to figure out how i can click on the colour in the menu and as soon as i click the menu option the Figure gets redrawn with the chosen colour. I probably need to write some message map but i cant figure out how.
Thanks david
|
|
|
|
|
Use:
InvalidateRect(NULL);
|
|
|
|
|
Can someone point me in the right direction please:
I need to figure out the these formulas to draw lines, but I'm not catching the gist of the formulas to display the data line.
The first line will start at x,y = (0,0) and end at x,y = (pi/4, 0.707). See Below
Samples Start End
1 0,0 pi/4,0.707 ---- Does this equate to 0.785398163 ------ ?
2 pi/4,0.707 pi/2,1
3 pi/2,1 3pi/4,0.707
4 3pi/4,0.707 pi,0
5 pi,0 5pi/4,-0.707
6 5pi/4,-0.707 3pi/2,-1
7 3pi/2,-1 7pi/4,-0.707
8 7pi/4,-0.707 2pi,0
Also, how is the formula with a number before the pi figured out? Is it the number * pi and the do the division on the number after the divisor sign?
Thanks to anyone who can help
FrankieB
|
|
|
|
|
yes, 3pi/4 = 3 *pi/4. The order of operation is unimportant.
Obviously you can't chart to a decimal point, these numbers need to be multiplied by something to become meaningful.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
The general formula to generate these numbers (if that's what you were after, your post is unclear to me) seems to be in pseudocode
<br />
start at 0,0<br />
number1 = linenr/4 * pi<br />
number2 = something like cos/sin of number1<br />
|
|
|
|
|
Can you clarify your suggestion:
What is - linenr/4 * pi
How do you use the cos and sin functions?
Thanks
|
|
|
|
|
For every line of your output: the first number corresponds to the linenumber divided by 4 and multiplied by pi, and the second number corresponds to the something like the sin/cos of the first number. sin/cos/sinh/cosh/acos/asin are in the C++ CRT. I'm not gonna explain their use, your teacher should.
|
|
|
|
|
Hello
Is it possible to use iostream, fstream with embedded Visual C++ 4?
I havo to port an application that uses this libraries to Pocket PC 2003, and seems that iostream, fstream etc are not present in eVC 4.
I´m using evc4 with service pack 4 and Pocket PC 2003 sdk.
Thanks in advance.
|
|
|
|
|
If not, then it's not C++.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hello,
I'm having a little problem. I don't get any compile or link errors
for this code, but when I run it I get:
Debug Assertion Failed!
Program: ...
File: fopen.c
Line: 53
Expression: file != NULL
<br />
#include <iostream><br />
#include <fstream><br />
<br />
using namespace std;<br />
<br />
unsigned char *openFile(char *, int&);<br />
<br />
int main(int argc, char **argv) {<br />
unsigned char *buffer;
char *fileName;<br />
int length;<br />
<br />
if (argc != 1) {<br />
cout << "Usage: " << argv[0] << " <pcap_file>" << endl;<br />
exit(1);<br />
} else {<br />
fileName = argv[1];<br />
buffer = openFile(fileName, length);<br />
}<br />
<br />
return 0;<br />
}<br />
<br />
unsigned char *openFile(char *fileName, int &length) {<br />
char *temp_buffer;<br />
unsigned char *buffer;<br />
ifstream theFile;<br />
<br />
theFile.open(fileName, ios::in|ios::binary);<br />
if (!theFile) {<br />
cout << "Can't open file " << *fileName << "!" << endl;<br />
exit(1);<br />
}<br />
<br />
theFile.seekg(0, ios::end);<br />
length = theFile.tellg();<br />
theFile.seekg(0, ios::beg);<br />
<br />
temp_buffer = new char [length];<br />
buffer = new unsigned char [length];<br />
<br />
theFile.read(temp_buffer,length);<br />
theFile.close();<br />
<br />
buffer = (unsigned char *) temp_buffer;<br />
<br />
return buffer;<br />
}<br />
The last delete[] temp_buffer; causes an assertion failure too,
when uncommented. I assume I'm makeing a really simple mistake. Anyone see it?
|
|
|
|
|
cockytrumpet wrote:
// delete[] temp_buffer; // why not!?
Easy - because if you delete it, you can't return it.
cockytrumpet wrote:
What's an assertion failure?
It means that the ASSERT macro has been used to make sure that the programmer ( in this case, someone at Microsoft, or who sold them a library ) has made correct assumptions. To get to the bottom of this, the best thing is to look at the file in question, see where the ASSERT is, and what it means.
<br />
FILE * __cdecl _tfsopen (<br />
const _TSCHAR *file,<br />
const _TSCHAR *mode<br />
,int shflag<br />
)<br />
{<br />
REG1 FILE *stream;<br />
REG2 FILE *retval;<br />
<br />
_ASSERTE(file != NULL); <- there it is<br />
_ASSERTE(*file != _T('\0'));<br />
_ASSERTE(mode != NULL);<br />
_ASSERTE(*mode != _T('\0'));<br />
<br />
<br />
<br />
<br />
if ((stream = _getstream()) == NULL) {<br />
errno = EMFILE;<br />
return(NULL);<br />
A null filename is being passed to this function. I reckon the problem is that you're grabbing the second parameter on the command line ( argv[1] ) instead of the first ( argv[0] ). Or is the first one a special value ? Either way, the argument you're grabbing is null.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
cockytrumpet wrote:
if (argc != 1)
{
cout << "Usage: " << argv[0] << " <pcap_file>" << endl;
exit(1);
}
else
{
fileName = argv[1]; // argv[1] is invalid when argc equals 1
...
The condition in the if statement should be comparing against 2.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello,
I`m trying to code an application that will remain in taskbar.. or like a system process. Can anyone give me some tips from where to start?
|
|
|
|
|
do you mean in the system tray next to the time? Take a look here
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
I guess that helps a little..but i still need a ssh client src, so a user can log in to a server and then go to tray.
Thanks in advance.
|
|
|
|
|
You can write a Windows NT system service and then have a separate applciation communciate to it using some form of interprocess communication. The secondary applet can appear in the system tray. It is not common, or the preferred method, to have a single application run as a service AND provide a user interface. You run into issues when the user logs off.
|
|
|
|
|
hello
1.
I tried putting some of my code that uses MFC inside a ordinary WIN32 dll and I get an error like this
nafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in otherdll.obj
Release/otherdll.dll : fatal error LNK1169: one or more multiply defined symbols found
this error I get whenever I try to #include some mfc headers that I need.
is there anyway to make a win32 dll accept MFC or do I have to make a mfc dll?
2.I dwd some sources of mfc dll and it seems like you can only import functions from them from MFC apps
can you not do the same from win32 apps?
and if so how?
3.I may need to send to the function I call from the dll a pointer to a IWebBrowser2 object
Is this possible?
does the dll know about IWebBrowser2? or does this not matter because pointer is pointer?
please reply to these questions
thank you in advance
|
|
|
|
|
Spiritofamerica wrote:
nafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in otherdll.obj
See here for possibilities.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
to lazy to log on
anyone have anything on the third issue????
|
|
|
|
|