|
I am working on a project where Im reading values from a machine every second, I then increment these values in a file, and then graph this file, every second I reset the plot and graph it again with the new values, when I reach the end of the upper bound of the x-axis, I want the lower and upper bounds to increment by 1 every second, Im working inside a forever loop and the code looks like so:
x=0; y=0;<br />
char* s;<br />
for( ;; )<br />
g1.plot_dataFile("data.dat", "test");<br />
Sleep(1000);<br />
g1.reset_plot();<br />
<br />
x++;<br />
if(x>20)
{<br />
y++;<br />
sprintf(s, "set xrange [%i:20+%i]", y, y);<br />
g1.cmd(s);<br />
}<br />
}
g1.cmd(string s) is a function to send commands to an external plotting application, and needs to take strings
While running, when x reaches 20, I get "Run-Time Check Failure #3 The variable 's' is being used without being defined."
Any help please!!!
We have a mathematician, a different kind of mathematician, and a statistician!
|
|
|
|
|
did you post all of your code? It looks like s never gets a value at all! You simply declare it:
char *s;
But never assign anything to it.
(p.s., at the very least, you should assign NULL to it when it is first created. Just good programming practice. )
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
Your right, I just set a large buffer for s and it worked
char s[1024] = {0};
Thanks v.m.
We have a mathematician, a different kind of mathematician, and a statistician!
|
|
|
|
|
allocate a space in the s pointer before 'sprintf'ing in it
try calloc or a big buffer
like char s[1024] = {0};
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Excellent, that worked a charm,
Thanks!
We have a mathematician, a different kind of mathematician, and a statistician!
|
|
|
|
|
Just curious, but shouldn't x be reset to 0 once it exceeds 20?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
No!, what i want is the graph to increment indefinatly every second, so when x reaches 20 then the lower and upper bound of the x-axis on the graph will increment, in other words the x-axis will show from 1-21, then 2-22, 3-23, and so on.
We have a mathematician, a different kind of mathematician, and a statistician!
|
|
|
|
|
Hey everyone how do I get rid of flickering in a childview in an mfc app? I have to views divided by a splitter bar. I've tried using CMemDC and I believe it gets rid of the flicker, however it seems to remap my view so stuff is drawn in a different location then what it is supposed to be.
my view's OnDraw looks like this
{
CMemDC pDC(dc);
CDocument* pDocBase = GetDocument();
CBaseStationDoc* pDoc = (CBaseStationDoc*)pDocBase;
CRect rcClient;
GetClientRect(&rcClient);
// Fill Background Color, Black
pDC->FillSolidRect(rcClient, RGB(0, 0, 0));
// Remap ViewportOrg to hor. center of client window and 100 pixels vertically top down.
int nXCoord = rcClient.Width()/2;
int nYCoord = rcClient.Height()/2;
pDC->SetViewportOrg(nXCoord, 100);
// Draw Robot Sensors
DrawSensors(nXCoord, nYCoord, pDC);
pDC->SetViewportOrg(nXCoord, nYCoord);
// Draw Sensor Table
DrawTableOfSensors(pDC);
}
When this code executes I can only see the bottom right quarter of what I normally see when the CMemDC line above is commented out, and dc is changed back to pDC
Any ideas?
|
|
|
|
|
Try making sure that the parent window of this is returng FALSE from it's handling of WM_ERASEBKGND. Also, making the parent window's background brush NULL may also help (see PreCreateWindow and AfxRegisterWndClass).
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Well its stopped flickering, but the viewportorg is all screwed up or something because of the CMemDC class.
If you type in CMemDC in google or something you'll see what I'm talking about.
|
|
|
|
|
I have converted most of the VCF to now store it's string data in unicode (UTF16).
If the program is running on Win9.x it translates strings back down to ansi. What I am not sure of is how, given a certain locale, do I know which char set (or code page?) to use?
For example, lets say I want to draw the text for "Hello" in polish. When converted from Unicode to ansi, with the default ACP, I end with certain values that are beyond the ascii number 128.
Does changing the locale (using SetThreadLocale) also change to the right char set? If it doesn't then how do I know which to use? Is it up to me to figure this out? I am assuming that "char set" and "code page" mean the same thing.
I am presuming that if I do not set this correctly, then when I translate the unicode to ansi string, and draw it, it will not draw the right characters.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Actually, I believe the charset used to display a string has to do with the font used to render the text. A font can be created with a particular character set (assuming that font supports the charset you specify.)
When using WideCharToMultiByte, you can specify the code page. I've always used the default CP_ASP and it seems to work, as long as the font is correct, but I tend to just read strings from a file and display them - nothing much more complicated than that.
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
Ahh, OK that makes sense. Do you remember/know how to do this?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
CreateFont takes a charset as one of its parameters. It can be ANSI_CHARSET, RUSSIAN_CHARSET, etc.
The trick, of course, is to make sure you have fonts supporting that character set. You can do this with EnumFontFamiliesEx .
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
OK I found it! Doh!
It's the fdwCharSet in CreateFont() or lfCharSet in LOGFONT. I've always wondered what the hell that was for
Would it make sense that I check the current locale, and based on this try and guess the right char set to use (falling back on a some sensible default like DEFAULT_CHARSET)?
some thing like:
LOGFONT lf;
if ( locale == polish || locale == russian etc... )
{
lf.lfCharSet = EASTEUROPE_CHARSET;
}
else if ( locale == arabic || locale == etc )
{
lf.lfCharSet = ARABIC_CHARSET;
}
and so on
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Yeah, that's more or less how I do it.
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
Hi. I have problem with simulating pessing ctrl+c. I'm subclassing an listview control and I want "press" ctrl +c. This is not a problem of focus because I tryed this in such a way:
<br />
HOOKS32_API LRESULT CALLBACK MessageListProc(HWND hwnd, UINT uiMsg,<br />
WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (uiMsg)<br />
{<br />
case WM_KEYDOWN:<br />
{<br />
int key=(int)wParam;<br />
if(key=='D' || key=='d')<br />
{<br />
PostMessage(hwnd,WM_KEYDOWN,(WPARAM)VK_CONTROL,(LPARAM)0x0001D001);<br />
PostMessage(hwnd,WM_KEYDOWN,(WPARAM)'C',(LPARAM)0x002E001);<br />
<br />
PostMessage(hwnd,WM_KEYUP,(WPARAM)VK_CONTROL,(LPARAM)0xC001D001);<br />
PostMessage(hwnd,WM_KEYUP,(WPARAM)'C',(LPARAM)0xC02E001); <br />
<br />
return 0;<br />
}<br />
}<br />
}<br />
<br />
return CallWindowProc(gfnMessageListProc, hwnd, uiMsg, wParam, lParam);<br />
}<br />
WPARAM values are the same as I found it using spy++. (0x00000000 and for UP 0xC0000000 not working too)
I want to copy in this way content of a listview item to clipboard. Probably this may fail because in control code to check if ctrl is still pressed GetKeyState(VK_CONTROL) function is used.
So this a question: Is my code in some sence wrong or is there any other way of simulating ctrl +c pressing
Pain is a weakness living the body
|
|
|
|
|
Use the SendInput API call
James
|
|
|
|
|
Hmm I did it here is a code
<br />
keybd_event( VK_CONTROL,<br />
0x45,<br />
KEYEVENTF_EXTENDEDKEY | 0,<br />
0 );<br />
keybd_event( 'C',<br />
0x45,<br />
0,<br />
0 );<br />
<br />
<br />
keybd_event( 'C',<br />
0x45,<br />
KEYEVENTF_KEYUP,<br />
0);<br />
<br />
keybd_event( VK_CONTROL,<br />
0x45,<br />
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,<br />
0);<br />
Pain is a weakness living the body
|
|
|
|
|
Using the basic code below, I am tring to change the caption(title bar) of the Dialog at run time. It does not work for me........my environment is net 7.1,MFC.
Any ideas on how to solve my problem?
void SystemAlign::OnBnClickedOk()
{
CPropertySheet mySheet;
mySheet.SetTitle(_T("Junk One"), 0);
mySheet.DoModal();
}
|
|
|
|
|
|
Is SetText() a method of CPropertySheet ?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
SetText is not available in my environment which is net 7.1, MFC
|
|
|
|
|
SetWindowText() is a class member of CWnd and so will work for any window, including dialogs & propertysheets.
|
|
|
|
|
|