|
PJ Arends wrote: Can you show the code for that loop? It almost seems to me that you are drawing the same line over and over again.
I'll do even better than that here is everything from my function:
<br />
void LoadAndDrawLines(void)<br />
{<br />
CPaintDC dc(this);<br />
CPen pen;<br />
pen.CreatePen(PS_SOLID, 1, 0x00FF0000);<br />
dc.SelectObject(&pen);<br />
CLineAccess *temp;<br />
int x = 1;<br />
POSITION pos;<br />
<br />
if(list.GetCount() > 0)<br />
{<br />
temp = (CLineAccess *)list.GetHead();<br />
pos = list.GetHeadPosition();<br />
dc.MoveTo(temp->GetStartX(), temp->GetStartY());<br />
dc.LineTo(temp->GetEndX(), temp->GetEndY());<br />
while(x < list.GetCount())<br />
{<br />
temp = (CLineAccess *)list.GetNext(pos);<br />
dc.MoveTo(temp->GetStartX(), temp->GetStartY());<br />
dc.LineTo(temp->GetEndX(), temp->GetEndY());<br />
x++;<br />
}<br />
}<br />
}<br />
LoadAndDrawLines() is called by OnPaint() btw. Also I will clean it up a bit later and move out all the pen stuff and more. Thanks for your help everyone
|
|
|
|
|
The usual pattern to enumerate over all of the elements in an MFC list is as follows:
CObList list;
POSITION position = list.GetHeadPosition();
while (position != NULL) {
element = list.GetNext(position);
} Try CObList[^] in the MSDN.
Software Zen: delete this;
|
|
|
|
|
I met a question when using vc++ .Net 2003,that is, in a project, I declare an array in .h file, but when I initialize that array in .cpp file, the compiler always show me errors. Then how to initialize an array in vc++ .Net 2003?
following is part of the .h and .cpp file.
.h file
#pragma once
#include "stdafx.h"
#include "miscgl.h"
#include "cmath.h"
#include "public.h"
class COpenGLScene
{
public:
COpenGLScene(void);
virtual ~COpenGLScene(void);
......
// backcolor of the scene.
GLclampf backColor[4];
........
};
.CPP FILE
#include <windows.h>
#include <stdio.h>
#include "StdAfx.h"
#include "openglscene.h"
COpenGLScene::COpenGLScene(void)
{
//zRot = 0;
SetCamera();
// First way:
// if using this way, the compiler will give me errors, why and how to using this way?
backColor[] = {0.4f, 0.4f, 0.4f, 1.0f};
// second way:
// if using this way to initialize it, it's OK.
backColor[0] = backColor[1] = backColor[2] = 0.4f;
backColor[3] = 1.0f;
this->isInitialized = FALSE;
}
Can I only initialize the array in the second way?
If I declare a static array, the method to initialize it is easy, but not all the array must be static one at any time.
So, how to initialize the array like the first way?
|
|
|
|
|
Using memcpy() allows you to use the first way.
GLclampf Temp[4] = {0.4f, 0.4f, 0.4f, 0.1f};
memcpy(backColor, Temp, sizeof(Temp) * sizeof(Temp[0]));
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I wouldn't use memcpy to initialize anything except arrays of integer and character types. Using it with struct 's is problematic, since the struct may have elements that shouldn't be copied directly (like pointers), or it may define an assignment operator.
Software Zen: delete this;
|
|
|
|
|
Thanks,a VC++ newer<it's me=""> has owned the world, internet is everything.
|
|
|
|
|
hello.
i need to get a html code so i can get same values out of it
but what is the best and the fastes way to do it?
|
|
|
|
|
Is there a procedure for copying folders from one place to another?
If there is such a procedure, could you tell me please which is it, and which parameters does it take?
THANK YOU!
|
|
|
|
|
|
All right... I saw it. But I don't understand a thing about that parameter, could you give me an example please?
|
|
|
|
|
|
I had already done that, but i still don't know how to use it... I'm quite new to visual c...
This is how i used it... and the program crashes. I guess i don't know how to handle the parameter...
LPSHFILEOPSTRUCT lpFileOp;
lpFileOp->pFrom="c:\\ad";
lpFileOp->pTo="d:\\";
lpFileOp->fFlags=FOF_ALLOWUNDO;
lpFileOp->wFunc=FO_COPY;
SHFileOperation(lpFileOp);
|
|
|
|
|
|
|
|
|
yesterday i spoke to soon...
i tried to use ravi's and dunn's programs... but they just didn't work, although ai included "c:\\DiskObject.h", or in the other case "c:\\CShellFileOp.h" and it gives the error message "undeclared identifier" when using the related procedures/functions
|
|
|
|
|
I have some experince in vc++.But i lack some fundamentals.If anybody having very good experince want to teach me i can pay for the service.If interested email me back.
Thanks
Ajit
ajitmittal@gmail.com
|
|
|
|
|
|
Hello..
I'm very new to visual C++ , I'm using a console application in Microsoft Visual Studio. NET..
I have a simple application where I want to get some parameters from the user, so i ask the user for it but when i type the answer and press enter on the keyboard the program just crashes (application has encountered a problem..send error to microsoft)
this is my code:
<br />
string host_name; <br />
<br />
printf("ENTER HOST NAME: "); <br />
<br />
<br />
scanf("%s",host_name); <br />
<br />
I have the following include files in stdafx.h file:
#include <iostream>
#include <string.h>
#include <tchar.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
I tried declaring host_name as char* but it still crashes.. tries using gets() but doesnt as well..
I also tried doing it the C++ way as follows :
<br />
<br />
using namespace std; <br />
<br />
cout<< "ENTER HOST NAME: "; <br />
cin >>host_name; <br />
And that also crashes the program..
Please tell me where the problem is.. Thank you for ur help..
|
|
|
|
|
Declare char host_name[100] and this will take care of the input string.
If you are willing to use string , then be sure you have the following:
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
SkyWalker
-- modified at 10:37 Saturday 22nd October, 2005
|
|
|
|
|
Thanks i'll used char hostname[100] and its fine now..
Is there any way that when the user inputs a password through the console that i can not make it display or have *** display instead ??
|
|
|
|
|
Capture the input and display what you want.
The following could do the trick:
#include <iostream>
using namespace std;1
.
.
char c, thePassword[100];
int i=0;
while((c = getch()) != '\n')
{
thePassword[i]=c;
putch('*');
}
then use thePassword within your code
SkyWalker
-- modified at 12:00 Saturday 22nd October, 2005
|
|
|
|
|
Hi
I tried to use what u mentioned above but it just skips allowing the user to enter the password (no * are even displayed ) and just goes forward with the program..
this is how i'm using it:
<br />
<br />
printf("ENTER PASSWORD: ");<br />
<br />
char c, password[100];<br />
int i=0;<br />
<br />
while((c = getchar()) != '\n') <br />
{ <br />
password[i]=c; <br />
putchar('*');<br />
}<br />
Am i doing something wrong ? thanks for the help..
|
|
|
|
|
You should be writing a console application.
(and collateral to that, increase i, otherwise everything goes to password[0] )
SkyWalker
|
|
|
|