|
You declare CProgressCtrl *progCtrlVar so you need to use
progCtrlVar->SetPos else you can declare CProgressCtrl progCtrlVar; and then use
progCtrlVar.SetPos <br />
<br />
<font size="2" color="#99ff66"><hr></font><div style="padding: 2px; text-align: left; color: rgba(255, 255, 255, 1); width: 80px"><font size="2" color="#99ff66">whitesky<br />
</font></div><hr>
|
|
|
|
|
I have just added a manifest to my project so that I can get the XP theme. I am having trouble getting the button colors so that my owner-drawn buttons can conform to the theme. I have tried GetThemeSysColor( hTheme, COLOR_BTNFACE ) but it doesn't return the correct value. I'm currently hard-coding (yuk) the RGB values for the button color in it's pressed and unpressed states but most certainly would like to be able to get the value programatically.
any ideas?
cje
cje
|
|
|
|
|
The proper identifier is TMT_BTNFACE, which has a different value than COLOR_BTNFACE.
Also note that button faces in the XP themes may have a gradiant, not a single color. If you want the same look, check out DrawThemeBackground or related functions.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I'm creating a class and trying to create a dynamic array of Prime Numbers. However, the compiler is giving this error:
c:\Documents and Settings\Jon\My Documents\Visual Studio Projects\IAD Practice and Assignment\C++ - Assignment\C++ - Assignment\01 - Primes\Previous Versions\v0.3\Primes\PrimeGen.cpp(39): error C2664: 'CPrimeGen::isPrime' : cannot convert parameter 1 from 'int' to 'int *'
class CPrimeGen
{
public:
CPrimeGen(int iUpperBound);
CPrimeGen(int iUpperBound, int iInterval);
CPrimeGen(int iLowerBound, int iUpperBound, int iInterval);
virtual ~CPrimeGen();
bool isPrime (int iNumber);
bool *PrimeNumber; // array of PrimeNumbers
};
PrimeGen.cpp
CPrimeGen::CPrimeGen(int iUpperBound)
{
int iNoOfIntervals = iUpperBound + 1;
this->PrimeNumber = new bool[iNoOfIntervals];
for (int iIndex = 1; iIndex <= iUpperBound; iIndex++)
{
if (isPrime(iIndex) == true)
{this->PrimeNumber[iIndex] = true;}
else
{this->PrimeNumber[iIndex] = false;}
}
}
CPrimeGen::CPrimeGen(int iUpperBound, int iInterval)
{
int iNoOfIntervals = (iUpperBound / iInterval) + 1;
this->PrimeNumber = new bool[iNoOfIntervals];
for (int iIndex = 1; iIndex <= iUpperBound; iIndex+= iNoOfIntervals)
{
if (isPrime(iIndex) == true)
this->PrimeNumber[iIndex] = true;
else
{this->PrimeNumber[iIndex] = false;}
}
}
CPrimeGen::CPrimeGen(int iLowerBound, int iUpperBound, int iInterval)
{
int iNoOfIntervals = ((iUpperBound - iLowerBound + 1) / iInterval ) + 1;
this->PrimeNumber = new bool[iNoOfIntervals];
for (int iIndex = iLowerBound; iIndex <= iUpperBound; iIndex+= iNoOfIntervals)
{
if (isPrime(iIndex) == true)
this->PrimeNumber[iIndex] = true;
else
{this->PrimeNumber[iIndex] = false;}
}
}
CPrimeGen::~CPrimeGen(void)
{
delete [] PrimeNumber;
}
bool CPrimeGen::isPrime(int iNumber)
{
/* hard-setting prime numbers */
if (iNumber <= 1) return false;
/* Algorithm: Sieve of Erastosthenes*/
int *mPrimeNumber;
mPrimeNumber = new int[iNumber + 1];
int iIndex;
/* initialize values
0: not set
1: prime
2: not-prime
*/
for (iIndex = 0; iIndex <= iNumber; iIndex++)
{mPrimeNumber[iIndex] = 0;}
iIndex = 2;
mPrimeNumber[iIndex] = 1;
for (iIndex = iIndex * iIndex; iIndex <= iNumber; iIndex += 2)
{mPrimeNumber[iIndex] = 2;}
iIndex = 2;
while (iIndex <=iNumber)
{
iIndex++;
// the next unset number is a prime
if (mPrimeNumber[iIndex]==0)
{ mPrimeNumber[iIndex] = 1;
// multiples of iIndex set as non-prime
for (int iInnerIndex = iIndex * 2; iInnerIndex <= iNumber; iInnerIndex += iIndex)
{mPrimeNumber[iInnerIndex] = 2;}}
}
// set return value
switch (mPrimeNumber[iNumber])
{ case 1:
{
delete [] mPrimeNumber;
return true;
break;
}
case 2:
{
delete [] mPrimeNumber;
return false;
break;
}
}
};
Jon
|
|
|
|
|
I just compiled this code without any compiler or link errors
cje
|
|
|
|
|
To address your problem, check to make sure your header file doesn't have it declared as:
bool CPrimeGen::isPrime(int* iNumber) .
Everything else looks okay from a warning/error point of view.
Some things you might want to consider:
Instead of storying true/false for each integer index, you might want to use a vector<long> or a CDWordArray to just story values that are prime numbers. Allowing a class that already handles memory allocation to store your array is less likely to introduce memory leaks and logic errors in your code (and makes it far less lines of code). Storing just the prime integers allows you to decrease your memory footprint when searching for prime numbers in a large range.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Which line has this error?
whitesky
|
|
|
|
|
Can I open solution in created in VS2005 professional in VS2005 Team Developer is any migration or any know issues going?
|
|
|
|
|
Do you mean Visual Stuio Team System (VSTS)? Visual Studio.NET is the majort part of VSTS. Besides, VSTS also incorporated project management, source control, bug reporting and so on.
Best,
Jun
|
|
|
|
|
Imagine I created my project in VS2005 professional at the moment when Team Edition wasn't released yet. Now I got Team Developer if I open solution/project in Team developer created in VS2005Prof is it going to migrate project or no migration needed?
|
|
|
|
|
No migration to your Visual Studio.NET projects. The Team System uses the very same VC++.NET as its compiler. Of course, you need to set up Team System, such as Microsoft Fundation Server. But this has nothing to do with project migration. Project migration is only required when your compiler is upgraded, such as VC6 to VC7 to VC8.
Best,
Jun
|
|
|
|
|
Thanks. Any tips convering projects fom VC6 -> VC8
|
|
|
|
|
In most cases, just load the VC6 project to VC8. The migration will be performed by VC8 automatically.
Best,
Jun
|
|
|
|
|
Yes thanks. I mean didyou discover any obvious issues I need to take care?
Thanks anyway for usefull info.
|
|
|
|
|
Hi fellows
I'm creating a app that reads data from a database and creates a graphic to show the results. I have a problem with this. I'll have a lot of registers, about 50000. I've think to sum the quantities of the registers and adjust the x-axis and the y-axis according this values. But for this I need to have a big screen resolution. How can I do this to show for the user adjusting in the window program? If anyone knows please tell me. I just want to get an idea, only this, not the entire solution.
I put a piece of code if anyone gets interesting
<br />
RECT tempRect, myRect;<br />
GetClientRect(hwnd, &tempRect);<br />
HBRUSH rectBrush;<br />
char cTemp3[10];<br />
int iSize = sizeof(tempPoint)/sizeof(POINT);<br />
int iXMarquees, iYMarquees, iXSpace, iYSpace = 0;<br />
POINT points[iSize], tmpPoint;<br />
LOGPEN LogPen;<br />
HPEN GraphicPen, LinesPen;<br />
tmpPoint.x = 2;<br />
LogPen.lopnStyle = PS_SOLID;<br />
LogPen.lopnWidth = tmpPoint;<br />
LogPen.lopnColor = 0x00000000;<br />
GraphicPen = CreatePenIndirect(&LogPen);<br />
for(int i = 0 ; i < iSize ; i++)<br />
{<br />
points[i].x = (ixClient * tempPoint[i].x)/400;<br />
points[i].y = (int)(((iyClient * tempPoint[i].y)/450)-iLine)+iYConst;<br />
}<br />
hdc = BeginPaint(hwnd, &ps);<br />
SelectObject(hdc, GraphicPen);<br />
SetBkMode(hdc, TRANSPARENT);<br />
TextOut(hdc, ixClient/2, iLine, TEXT("Olá"), sizeof("Olá"));<br />
Polyline(hdc, points, (sizeof(points)/sizeof(POINT)));<br />
iXGraphLine = tempRect.right-80;<br />
iYGraphLine = (tempRect.bottom-150)-iLine;<br />
tmpPoint.x = 2;<br />
LogPen.lopnStyle = PS_SOLID;<br />
LogPen.lopnWidth = tmpPoint;<br />
LogPen.lopnColor = 0x00FF0000;<br />
LinesPen = CreatePenIndirect(&LogPen);<br />
SelectObject(hdc, LinesPen);<br />
iXSpace = iXGraphLine/(iSize*2);<br />
iYSpace = iYGraphLine/(iSize*2);<br />
for(int i = 0, iXpos = iXSpace, iYpos = iYSpace, iXFont = 10 ; i < iSize*2 ; i++)<br />
{<br />
SelectObject(hdc, LinesPen);<br />
char cTemp10[5];<br />
MoveToEx(hdc, (iXpos-15), iYGraphLine-10-iLine, NULL);<br />
LineTo(hdc, (iXpos-15), iYGraphLine+10-iLine);<br />
itoa(iXpos, cTemp10, 10);<br />
cTemp10[5]='\0';<br />
<br />
SetTextAlign(hdc, TA_CENTER);<br />
TextOut(hdc, iXpos-(((strlen(cTemp10)*iXCaps)+iXChar)/strlen(cTemp10))-2, iYGraphLine+10-iLine, cTemp10, strlen(cTemp10));<br />
iXFont+=iXSpace/2;<br />
iXpos+=iXSpace;<br />
MoveToEx(hdc, 5, (iYpos-15)-iLine, NULL);<br />
LineTo(hdc, 25, (iYpos-15)-iLine);<br />
itoa(iYpos, cTemp10, 10);<br />
TextOut(hdc, 40, (((iYSpace*((iSize*2)-i))-4)-(((strlen(cTemp10)*iXCaps)+iYChar)/strlen(cTemp10))-2)-iLine, cTemp10, strlen(cTemp10));<br />
iYpos+=iYSpace;<br />
SelectObject(hdc, GraphicPen);<br />
SelectObject(hdc, CreateSolidBrush(0x00000000));<br />
if(i < 5)Pie(hdc, points[i].x-4, points[i].y-4, points[i].x+4, points[i].y+4, 10,10,0,0);<br />
}<br />
SelectObject(hdc, LinesPen);<br />
MoveToEx(hdc, 15, -iLine, NULL);<br />
LineTo(hdc, 15, iYGraphLine-iLine);<br />
MoveToEx(hdc, 15, iYGraphLine-iLine, NULL);<br />
LineTo(hdc, iXGraphLine, iYGraphLine-iLine);<br />
rectBrush = CreateSolidBrush(0x00FFFFFF);<br />
myRect.top = (tempRect.bottom-100-iLine*2);<br />
myRect.bottom = (tempRect.bottom-10-iLine*2);<br />
myRect.left = 50;<br />
myRect.right = 200;<br />
FillRect(hdc, &myRect, rectBrush);<br />
SelectObject(hdc, GraphicPen);<br />
MoveToEx(hdc, 60, ((myRect.bottom+myRect.top)/2)-30, NULL);<br />
LineTo(hdc, 130, ((myRect.bottom+myRect.top)/2)-30);<br />
TextOut(hdc, 160, ((myRect.bottom+myRect.top)/2-30-(((strlen("Lalala")*iXCaps)+iYChar)/strlen("Lalala"))+2), "Lalala", strlen("Lalala"));<br />
EndPaint(hwnd, &ps);<br />
DeleteObject(GraphicPen);<br />
DeleteObject(LinesPen);<br />
DeleteObject(rectBrush);<br />
ReleaseDC(hwnd, hdc);<br />
<code>
|
|
|
|
|
Where can we help? The number of registers? Adjusting x- and y-axis? What do you mean "a big screen"?
Please specify where your problem is.
Best,
Jun
|
|
|
|
|
Thanks for your help Jun Du. I need a help exactly for the things that you said. How can I adjust the x and y axis accroding with the number of registers When I said big screen I mean the user will have a big screen resolution to view all the registers, right?
Can you help again?
|
|
|
|
|
Alex Cutovoi wrote: How can I adjust the x and y axis accroding with the number of registers
I hope you know the possibly largest number of registers (grids?) in advance. Of course, you probably only draw the plot for actual number of available registers.
Alex Cutovoi wrote: When I said big screen I mean the user will have a big screen resolution to view all the registers, right?
You should know what Customer (or yourself) wants. There are two drawing options:
1) The size of plot is fixed.
2) The size of plot is proportional to the number of registers.
Either way, whenever the number of registers changed, you have to erase the plot and redraw everthing. There is no way to just "adjust". Since you are using GDI to draw, I assume you know how to draw and redraw. To avoid blinking, you probably want to use double-buffering, meaning drawing to a memory DC and copy to the screen when necessary.
Best,
Jun
|
|
|
|
|
Hi,
For some reason, the path of the .ini file is asked not be specified. The .ini file is located in the same place with .exe file. I tried the functions fopen(strIniFileName,"r") and GetPrivateProfileString( ..,..,..,..,..,strIniFileName), where strIniFileName = ".\\myINI.ini". Both functions worked well in debug process, but failed in execution. I am confused.
I am using VC++ 6, and working on Windows XP.
Could someone please give me an assistance. Many thanks in advance.
hli
|
|
|
|
|
Call GetCurrentDirectory to see where your app runs from and go from there.
Things like this happen when you start your app from a shortcut (with the Start In param missconfigured)
|
|
|
|
|
Good idea. I will try. Thank you very much.
hli
|
|
|
|
|
Actually one wants to use GetModuleFileName() if the ini file is in the same folder as the exe.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
You are right GetCurrentDirectory works from .exe file itself, but fails from shortcut. My application must be used remotely from shortcut. ???
hli
|
|
|
|
|
Run app from shortcut, getCurrentDirectory returns C:\Documents and Settings. I guess that GetModuleFileName is the same. I will try.
hli
|
|
|
|
|
I resolved this problem by adding work directory in "Start In" box in shortcut property. Many thanks.
hli
|
|
|
|
|