|
I use Application::Idle to calculate FPS, but it seems to be unsuitable. Becuase the Application::Idle does not like the CWinApp::Idle in MFC.
Application::Idle event is not called in every frame. Could somebody know how to calculate FPS in Visual C++ CLR project?
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Form1^ form1=gcnew Form1();
Application::Idle += gcnew System::EventHandler(form1,&Form1::Form1_Idle);
Application::Run(form1);
return 0;
}
public: System::Void Form1_Idle(System::Object^ sender, System::EventArgs^ e)
{
DWORD currentTime=GetTickCount();
DWORD deltaTime=currentTime-m_PlayCurrentTime;
m_PlayCurrentTime=currentTime;
m_FPS->FrameCnt++;
m_FPS->TimeElapsed+=deltaTime;
if (m_FPS->TimeElapsed >= 1000)
{
m_FPS->CalculateFPS();
m_FPS->TimeElapsed -= 1000;
m_FPS->FrameCnt = 0;
FPStoolStripStatusLabel->Text=L"FPS=" + m_FPS->dFPS.ToString();
}
}
|
|
|
|
|
akira32 wrote: Could somebody know how to calculate FPS in Visual C++ CLR
FPS of what? What frames?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
FPS is frame per second.
Sorry! m_FPS is customized strcut as below:
ref struct sFPS
{
sFPS()
{
Init();
}
void Init()
{
FrameCnt=0;
TimeElapsed=0;
dFPS=0;
}
void CalculateFPS()
{
dFPS = (Double)FrameCnt / (TimeElapsed/1000.0f);
}
DWORD FrameCnt;
DWORD TimeElapsed;
Double dFPS;
};
In MFC project, I can use the CWinApp::Idle to count the frame number for FPS. But in CLR project. Application::Idle is not always called(must have some windows messages be triggerred), so I cannot use it to calculate FPS if the mouse does not focus on the winform. I want to find a event that will be called at any time.
modified on Tuesday, November 24, 2009 12:14 AM
|
|
|
|
|
akira32 wrote: FPS is frame per second.
Right. But I asked "FPS of what? What frames?"
Video?
akira32 wrote: I want to find a event that will be called at any time
A Timer[^] maybe?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Not for video. I use for DirectX.
|
|
|
|
|
I guess I'm missing what you're trying to do.
It seems to me a FPS calculation should be done when each frame
(or multiple of frames) is rendered, not during an idle event,
unless the idle event is the only time a new frame is rendered.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
Is there any function or API, which give me the name of opened .exe or file name and path(by right click->Open or by double clicking) from any drive or desktop.
thanks
|
|
|
|
|
Look at tlhelp32.h and shellapi.h and the Process32Next function
|
|
|
|
|
Could somebody know the even for the scrolling of middle mouse scroll?
I want to update the client region when user scrolls the middle mouse scroll.
|
|
|
|
|
|
Hello Sir
How to Import C# DLL in C++ Application .please replay me
Thanks!!
Raju !!!
|
|
|
|
|
Yea its working fine ...
Raju !!!
|
|
|
|
|
I define a class MyObject. I want to use PropertyGrid to browse and modify the attributes of myObject (MyObject object).
Can I reach this goal? If the answer is "Yes". Could sombody tell me how to do?
ref class MyObject
{
public:
int x;
int y;
int rx;
int ry;
};
private: System::Void FormProperty_Load(System::Object^ sender, System::EventArgs^ e)
{
MyObject^ myObject=gcnew MyObject();
propertyGrid1->SelectedObject = myObject;
}
|
|
|
|
|
I had used public property to solve this problem. But... I meet another problem.
If SelectedObject is a nested object like basicobject, how to show the parameters of basiceffect in PropertyGrid?
public ref class BasicEffect
{
public:
BasicEffect(void)
{
}
virtual ~BasicEffect()
{
}
public:
[Browsable(true)]
property System::Boolean loop
{
bool get()
{
return _loop;
}
void set(System::Boolean value)
{
_loop=value;
}
}
private: System::Boolean _loop;
};
public ref class UIObject
{
public:
UIObject(void){_basiceffect=gcnew BasicEffect()};
virtual ~UIObject(void){};
public:
[Browsable(true)]
property int x
{
int get()
{
return _x;
}
void set(int value)
{
_x=value;
}
}
public:
[Browsable(true)]
property BasicEffect^ basiceffect2
{
BasicEffect^ get()
{
return _basiceffect2;
}
void set(BasicEffect^ value)
{
_basiceffect2=value;
}
}
private: int _x;
private: BasicEffect^ _basiceffect2;
};
modified on Thursday, November 19, 2009 3:32 AM
|
|
|
|
|
first please download the PDFLibNet.dll from here: http://www.codeproject.com/KB/files/xpdf_csharp/PDFViewer.zip[^]
it's ok like this:
<br />
Assembly a = Assembly.LoadFile("PDFLibNet.dll");<br />
but exception like this:
byte[] b = File.ReadAllBytes("PDFLibNet.dll");<br />
Assembly a = Assembly.Load(b);<br />
throwing FileLoadException, telling me it could not verify the code or could not pass policy check. .net thinks that it is not a valid assembly.
I found a solution here: http://nonodes.spunow.co.uk/2009/04/assemblyload-c-cli-assembly-gives.html[^] telling me to build the C++ assembly with /clr:safe, but is there any other way out?
Regards,
unruledboy_at_gmail_dot_com
http://www.xnlab.com
modified on Tuesday, November 17, 2009 10:16 PM
|
|
|
|
|
I want to modify the AutoScrollMinSize of Form1 by the code as below:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
this->AutoScrollMinSize.Width=1000;
this->AutoScrollMinSize.Height=1000;
}
But it still not be active. Could somebody know how to modify the AutoScrollMinSize of Form1?
PS:already set Form1's AutoScroll as True.
modified on Tuesday, November 17, 2009 3:24 AM
|
|
|
|
|
a Size is a struct, hence a value type; you can't just modify part of it to modify the object. Assign a new Size with the width AND height you want.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Size is a struct, so when you directly modify its properties, you are actually modifying a copy of it. (Actually modifying two copies of it in your code, one for width and another for height ).
Use something like this:
this->AutoScrollMinSize = gcnew Size(1000,1000);
|
|
|
|
|
Could somebody know how to put any type controls on Toolstrip?
I want to put TrackBar and DomainUpDown controls to the Toolstrip.
|
|
|
|
|
System::Drawing::Bitmap ^pBitmap;
System::IntPtr intPtr = pBitmap->GetHbitmap();
//How to convert this IntPtr to HBITMAP
//HBITMAP hbitMap = intPtr
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
Assuming HBITMAP's type is defined somewhere (it is a HANDLE,
which is a void*)
HBITMAP hbitMap = intPtr.ToPointer();
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
FolderBrowserDialog FolderBrowserDialog1;
//FolderBrowserDialog1.RootFolder=System::Environment::SpecialFolder::Startup;
|
|
|
|
|
Something like,
FolderBrowserDialog folderBrowser;
folderBrowser.SelectedPath = Application::StartupPath;
Best wishes,
Navaneeth
|
|
|
|
|
The application's current working directory can be obtained
with System::IO::Directory::GetCurrentDirectory().
The current working directory is not necessarily the same as
the startup path
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks. I has solved this problem.
|
|
|
|