|
Thanks DavidCrow,
I think you agree with my points.
--------------------
If we only provide one version of new in current class, compiler will stop in current class searching for the other 2 forms of overloaded new even if current class does not provide it (they are defined in base class or global space).
The issue of providing only one form of new is, when other class uses the other two forms of new, since in current class, it is not implemented, there will be compile error.
--------------------
regards,
George
|
|
|
|
|
dear all
the following gbest is a constant array which was calculated previously, but how to make constant which values of whole this array keep fixed, don't change along with for loop below: thanks.
gbest = [9][3][4], but here 9 maybe change between 0-9 in next time.
for ( int ii =0; ii<10; ii++)
{
for (int j = 0; j<3; j++)
{
for (int k = 0; k<4; k++)
{
vn[ii][j][k] = w*v[ii][j][k] + c1*rand()*(pbestArray[ii][j][k]-
x[ii][j][k]) + c2*rand()*(gbest[ii][j][k]-x[ii][j][k]);
v[ii][j][k] = vn[ii][j][k];
xn[ii][j][k] = x[ii][j][k] + v[ii][j][k] + a1*(g-fitness[ii]);
x[ii][j][k] = xn[ii][j][k];
}
}
}
thanks a lot.
Li Zhiyuan
5/10/2006
|
|
|
|
|
li zhiyuan wrote: the following gbest is a constant array which was calculated previously, but how to make constant which values of whole this array keep fixed, don't change along with for loop below: thanks.
gbest = [9][3][4], but here 9 maybe change between 0-9 in next time.
I'm dizzy from reading this? Please explain.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
the following is my code:
for (int i = 0;i<10;i++)
{
minValue = fitness[9];
if (fitness[i] <= minValue )
{
minValue = fitness[bb];
for (int j = 0; j<3; j++)
for (int k = 0; k<4; k++)
gbest[i][j][k]=x[i][j][k];
for (int ii =0; ii<10; ii++)
{
for (int j = 0; j<3; j++)
{
for (int k = 0; k<4; k++)
{
vn[ii][j][k] = w*v[ii][j][k] + c1*rand()*(pbestArray[ii][j][k]-x[ii] [j][k]) + c2*rand()*(gbest[i][j][k]-x[ii][j][k]);
v[ii][j][k] = vn[ii][j][k];
xn[ii][j][k] = x[ii][j][k] + v[ii][j][k] + a1*(g-fitness[ii]);
x[ii][j][k] = xn[ii][j][k];
}
}
}
}
}
}
dear friend
firstly, i need to determine gbest in first 10 loop, and then the following formaula is following second l0 loop apart from gbest, because gbest is constant relave to second loop..but how to make gbest is a constant,,no change according my first loop.....so far, gbest could not get value from s[ii][j][k], i don't know why? could help me? thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
Could you explain more clearly your requirement?
It seems you want to keep constant gbest in the last loop, but you code actually keeps gbest elements constant inside the loop.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
li zhiyuan wrote: firstly, i need to determine gbest in first 10 loop...
What are you needing to determine?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
make counter for how many time you were running the loop. Via checking the counter you decided to change your gbest value.
int looped = 0;
....
if( looped < 10 )
{
gbest....
}
//loop end
looped ++;
Greetings from Germany
|
|
|
|
|
dear all
how to use getchar(), when i used, compiler showed i need to declare first. i use win32 console applicatioin so far. thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
So did you include stdio.h like the documentation shows?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all. Im trying to find out whether a window is active or not. This is what i have so far...
<br />
#include <iostream><br />
#include <windows.h><br />
using namespace std;<br />
<br />
int main(){<br />
Sleep(1000);<br />
if(strcmp("00315434", GetForegroundWindow()) == 0){<br />
cout << "Notepad found! " << endl;<br />
}<br />
return 0;<br />
}<br />
</windows.h></iostream>
But i get an error.
error C2664: 'strcmp' : cannot convert parameter 2 from 'struct HWND__ *(__stdcall *)(void)' to 'const char *'
How do i compare what GetForegroundWindow returns so i can make my app look for a specific window? Thanx in advance!
|
|
|
|
|
dellthinker wrote: But i get an error.
error C2664: 'strcmp' : cannot convert parameter 2 from 'struct HWND__ *(__stdcall *)(void)' to 'const char *'
The GetForegroundWindow() function returns a handle to the foreground window, while the second argument to strcmp() is a null-terminated string (to compare). Of course, you already knew all of this.
dellthinker wrote: How do i compare what GetForegroundWindow returns so i can make my app look for a specific window?
By also employing GetWindowText() . Otherwise, checkout FindWindow() .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Ok so now im using GetWindowText() and it seems to capture all window titles. But i need it to look for a specific window, Notepad in this case.
Here is my code:
<br />
#include <iostream><br />
#include <windows.h><br />
using namespace std;<br />
<br />
<br />
int main(void)<br />
{<br />
HWND currenthwnd,hwnd;<br />
char s[1024];<br />
hwnd=NULL;<br />
while (1){<br />
Sleep(1000);<br />
currenthwnd=GetForegroundWindow();<br />
if (currenthwnd!=hwnd){<br />
hwnd=currenthwnd;<br />
GetWindowText(hwnd,s,1024);<br />
printf("%s\n",s);<br />
}<br />
if(strstr(s, "Notepad") == 0){<br />
cout << "Notepad is open! " << endl;<br />
}<br />
else{<br />
cout << "Its not open " << endl;<br />
}<br />
}<br />
return 0;<br />
}<br />
</windows.h></iostream>
Problem is when the program is running it prints Notepad is open when it really isnt. Can someone help me fix this? Thanx in advance!
|
|
|
|
|
dellthinker wrote: Problem is when the program is running it prints Notepad is open when it really isnt.
dellthinker wrote: if(strstr(s, "Notepad") == 0)
Shouldn't that be
if(strstr(s, "Notepad") != 0)
cout << "Notepad is open! " << endl;
}
?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanx Mark, your solution worked.
|
|
|
|
|
hi, dellthinker
The string "Notepad" can be in any other window's title.
strstr(s, "Notepad") == 0 doesn't mean any thing.
Try this one, hope it will be helpful.
HWND hWnd = FindWindow("Notepad", NULL);
if (hWnd)
{
printf("Notepad is open! ");
}
else
{
printf("Its not open");
}
============
Einstein
Seeing is believing.
|
|
|
|
|
|
Please make your tests elsewhere.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Test is failed because you got down voted.
|
|
|
|
|
When I move the mouse in the client, the computer becomes noisy, the sound like that reading data from harddisk.
When I comment out
g.DrawImage(m_pMemBmp,0,0);
it become quiet.
How to make it be quiet?
void CMyDlg::OnMouseMove(UINT nFlags, CPoint point)
{
Graphics g(GetSafeHwnd());
g.DrawImage(m_pMemBmp,0,0);
CDialog::OnMouseMove(nFlags, point);
}
|
|
|
|
|
Add more RAM?
Use a smaller bitmap?
Those are actually serious answers. I'm not expert on GDI+, but I know it can do all sorts of clever things for you, which may require it to make multiple copies of a bitmap to work on, so it may be greedier than you think.
Now you'll tell me the bitmap is only 64x64 pixels, and I'm talking rubbish!
Iain.
|
|
|
|
|
The bitmap is created according to the size of the client area.
I create a Graphics object using the bitmap, in OnCreate
<br />
CRect rc;<br />
GetClientRect(&rc);<br />
Graphics g(GetSafeHwnd());<br />
m_pMemBmp=::new Bitmap(rc.Width(),rc.Height(),&g);<br />
m_pMemGraphics=::new Graphics(m_pMemBmp);<br />
m_pMemGraphics->Clear(Color::White);<br />
|
|
|
|
|
Hi all!
I am working on a application which is performance intensive. The bulk of the application is spread across several shared DLL modules for reusability. I have used C++ for the benefits of OOP, and the system is functioning well.
I am designing a scripting system to facilitate future expansion with cross-platform support. I have a basic scripting engine working. Scripts are able to link to and call C-style functions from dll modules. I am finding the need to use class within the scripting system, and have found several ways for which I can have a script link to a DLL module and use classes.
The key two constraints here are:
- performance, there are many small methods which will be called upon extremely frequently and so it is very important to minimize overhead here at all other costs.
- Cross-platform compatability at build time only, scripts will be cross-platform compatible already.
Idea #1 - Allocate and release objects from within the DLL using exported C functions. Add additional exported C functions for each class method, and convert all class methods into simple inline wrappers.
Problem: This may cause double function calls when interacting with class objects
Idea #2 - Somehow devise an approach which can link to exported C++ functions where the 'this' value could somehow be provided.
Problem: It is very important that this is compatible with other compilers, unfortunately (as far as I can tell) there is no standard for this.
Link functionality could be specialised for each platform (i.e. Windows, UNIX) simply by using seperate implementation files. Sadly, the same cannot be said for different compilers as there are many different compilers, and there is no way that I could support all of them.
It would be great to hear your ideas and experiences with similar situations. Is there a better way which I haven't yet found?
Many thanks!
Lea Hayes
|
|
|
|
|
Hi, I have developed an application that uses the winscard API to work with Smart Cards. The problem is that when Windows XP locks the session where the application is open and running, and the application calls the function SCardGetStatusChange, the call does not return any more and in the System Log of the Event Viewer appears the following error:
Smart Card Reader 'OMNIKEY CardMan 3x21 1' rejected IOCTL GET_STATE: Access is denied.
Source: SCardSvr
Event_ID: 610
I would really appreciate any hint about this problem. If I you know of a better place to post this question could you please tell me and I'll remove the question from this forum if it is an off-topic.
Thanks,
Federico
|
|
|
|
|
I have been doing smartcard application programming with WinSCard library for my company, which is a smartcard reader vendor, for 5 years. I cannot be sure if there isn't anything wrong in your code. But from my experience, most often this situation was caused by the fault of the device driver.
What would be the result when you:
1. Manually eject the card? (The call to SCardGetStatusChange should return immediately! )
2. Set a minimal timeout for the 2nd argument of SCardGetStatusChange.
Maxwell Chen
|
|
|
|
|
Thanks Maxwell!
The problem is that I can't reproduce this problem. This is happening in a client, and I have just the logs that I have introduced. The SCardGetStatusChange is called by a background thread in my application. The client tells me that after unlocking the Windows session the application does not detect anymore card insertions/removals. Reading the logs, I have found that the thread enters SCardGetStatusChange and it never comes out; and, of course, in the System log of the Event Viewer appears the message that I have reproduced above.
I will try with a minimal timeout and see what happens, exactly when the thread does not return anymore.
Thanks,
Federico
|
|
|
|