|
Hello All,
I have a large legacy application that I will soon be updating with some new development. The new features will require a fair amount of owner draw stuff. My concern is that some of the application's current owner draw stuff runs slowly on Vista. Win2K and WinXP run great. I'm not sure what's causing the slowness on Vista, but I want to figure it out before the new development. I'm not sure whether it's poor programming (although it seems pretty adequate to me) or whether I need to swap out all the pDC->MoveTo() pDC->LineTo() etc... for some other methodology or switch to a Directx equivilent or something. I'm developing in Visual Studio 2003 so perhaps upgrading to VS2008 would fix the problem?
Anyone have any similar experience? Any thoughts?
Thanks in advance.
|
|
|
|
|
Windows Vista graphics subsystem is designed to work with Direct3D. Existing graphics interfaces, such as GDI, GDI+, and older versions of Direct3D are still supported in Windows Vista, but are internally remapped where possible. So you will surely experience a performance hit. To compromise these things, you need high performance hardware.
The operating system itself using lot of resources and running many background services than Windows XP. You need to have better computer components than previous. If your application is drawing intensive, you may need a good graphics card as well.
Direct2D [^]is a new technology which is being developed by Microsoft to replace GDI and GDI+. It's currently supported in Windows 7 and it will be the future of 2D Drawing.
Check Tim Anderson's Performance test [^]with Windows XP and Vista
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Thanks Sarath. These are quite helpful. Tim Anderson's article seemed to be expressing exactly what I have experienced. Since customers will be getting this software, I can't demand they upgrade their hardware so I will look into the Direct2D.
Thanks again.
|
|
|
|
|
It occurs to me -- what's the support for Direct2D in Vista, XP and Win2K? Do you have any idea about this?
|
|
|
|
|
Hello
I'm trying to use the FSCTL_GET_VOLUME_BITMAP Control Code(which gets a bitmap of the used/unused clusters on the volume). It's been working fine on NTFS but when I try it on a FAT32 partition it doesn't seem to work that well. It doesn't error or something but the retrieved bitmap isn't representative. Firstly is off by a few clusters and the cluster representation (used or unused) isn't valid.Can anyone help me with this?
Thanks.
|
|
|
|
|
Does any one know how can I export the strings from the string table in Resource view to a file may be .xls or .csv .... I would think there would be a way to read this table and write it into a file? Any commands to do this?
Thanks
sft
|
|
|
|
|
How about writing a simple for cycle which scans thorough the string IDs from the lowest to the highest, loads the strings and then saves them in whatever format you wish to save it in? Something like
CString String;
for (int id = LOWEST_STR_ID; id <= HIGHEST_STR_ID; id++)
if (String.LoadString(id)) { }
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Nice idea.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The resource script (.rc) file is a text one, you may read, parse it and export the strings.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I wrote this code for a school project,since i use vista and dos doesn't work properly on it ,i normally use the emulator DOSBOX.The problem is this program runs well on DOSBOX but not on the normal DOS platform. It gives an error
<code> Floating point error:domain Abnormal program termination</code>
Here's the code,its on text file encryption.My school requires me to use the ancient "turbo c++ 3.0"
<pre>#include<string.h>
#include<stdio.h>
#include<fstream.h>
#include<conio.h>
#include<math.h>
int strtoken(char k[]) {
int N = strlen(k);
int sum = 0 ;
for (int q=0;q<N;q++)
sum+= (int) k[q] ;
int tok = sum%255;
return tok;
}
int strtoken2(char k1[]) {
int N1 = strlen(k1);
int sum1 = 0,t=0;
for (int q1=0;q1<N1;q1++)
{
t = (int) k1[q1];
t=pow(2,t);
sum1+= (t%255) ;
}
int tok = sum1%255;
return tok;
}
int main() {
clrscr();
int choice,num;
char ifname[20],ofname[20],Key[20],ch;
start:
clrscr();
cout<<"\n------------------------------------------------------------------------------\n";
cout<<"Texcrypt 1.0.\n";
cout<<"\n";
cout<<"------------------------------------------------------------------------------\n\n";
cout<<"\t\t\t*-------------------*\n"<<"\t\t\t| 1) Encrypt. |\n"<<"\t\t\t| 2) Decrypt. |\n"<<"\t\t\t| 3) Help. |\n\t\t\t| 4) Exit. |\n"<<"\t\t\t*-------------------*\n";
cout<<"\nEnter your choice: ";
cin>>choice;
if(choice==3) {
clrscr();
cout<<" Instructions \n ------------- \n\n\n 1.Choose whether to encrypt or decrypt a file ";
cout<<"\n 2.Enter the input and output filenames (if the file is in same directory as texcrypt ,if not,then enter the full path of the file)";
cout<<"\n 3.Enter the key to encrypt/decrypt the file with(your file will be encrypted on the basis of the key entered).";
cout<<"\n 4.The output file will be your encrypted/decrypted file";
cout<<"\n\n\n\nPress any key to return ...... ";
getch();
goto start;
}
else if(choice==4)
return 0;
char text[3][20] = {"","encrypted","decrypted"};
clrscr();
cout<<"Enter input filename : ";
gets(ifname);
fflush(stdin);
cout<<"\n";
int i;
ifstream infile("");
ofstream outfile("");
infile.open(ifname);
if(!infile) { // if file is not found
cout<<"Error:File not found";
goto end;
}
cout<<"Enter output filename : ";gets(ofname);fflush(stdin);
cout<<"\n";
outfile.open(ofname);
switch(choice) {
case 1:cout<<"Enter key: ";
for(i=0;;i++)
{
Key[i]=getch();
if (Key[i] == '\r')
break;
cout<<"*";
}
Key[i] = '\0';
<b>
<big>// I think the error is somewhere overhere</big></b>
int token= strtoken(Key);
int token2= strtoken2(Key);
fflush(stdin);
cout<<"\n";
while (infile) {
while(infile){
infile.get(ch);
if(!infile){
cout<<"\nThe file was successfully encrypted.";
getch();
goto end;
}
ch=char((ch+token-(token2))%255);
outfile.put(ch);
}
}
break;
case 2:
cout<<"Enter key: ";
for(i=0;;i++){
Key[i]=getch();
if (Key[i] == '\r')
break;
cout<<"*";
}
Key[i] = '\0';
cout<<"\n";
fflush(stdin);
int dtoken=strtoken(Key);
int dtoken2=strtoken2(Key);
while(infile) {
while(infile) {
infile.get(ch);
if(!infile)
{
cout<<"\nThe file was successfully decrypted.";
getch();
goto end;
}
ch=char(((ch)-dtoken+(dtoken2))%255);
outfile.put(ch);
}
}
break;
}
//end switch
end:
infile.close();
outfile.close();
cout<<"\n\n\nPress any key to return ......... " ;
getch();
goto start;
return 0;
}
</pre>
|
|
|
|
|
Hint: narrow the problem down to just small handful of relevant lines. No one wants to wade through all of this when you could do most of it yourself.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
sorry about that,here is where i think the problem is
cout<<"Enter input filename : ";
gets(ifname);
fflush(stdin);
cout<<"\n";
int i;
ifstream infile("");
ofstream outfile("");
infile.open(ifname);
cout<<"Enter output filename : ";gets(ofname);fflush(stdin);
cout<<"\n";
outfile.open(ofname);
second place
---------------
cout<<"Enter key: ";
for(i=0;;i++)
{
Key[i]=getch();
if (Key[i] == '\r')
break;
cout<<"*";
}
Key[i] = '\0';
int token= strtoken(Key);
int token2= strtoken2(Key);
fflush(stdin);
cout<<"\n";
while (infile) {
while(infile){
infile.get(ch);
if(!infile){
cout<<"\nThe file was successfully encrypted.";
getch();
goto end;
}
ch=char((ch+token-(token2))%255);
outfile.put(ch);
}
}
|
|
|
|
|
Vivek Narayanan wrote: t=pow(2,t);
I suspect your problem has to do with this statement. Change it to:
t = pow(2.0, t); Since this is a C++ project, why are you using char instead of string ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
i tried that,it didn't solve the problem,it works in the emulator DOSBOX but not on the real DOS platform,could this be some sort of memory problem?
|
|
|
|
|
A good technique to learn early in one's career in programming is this: when you have a problem where you don't have any idea where the problem lies, comment out sections, placing hard coded (good) values where necessary and see if the unexplained problem goes away. This is a good place to start when you don't know where else to start.
|
|
|
|
|
Hello,
i would encode a wavebuffer to the ogg speex.
My actually code is like this:
HWAVEIN hWaveIn;
WAVEHDR WaveHdrIn[AUDIOBUFS];
BYTE BufferIn[AUDIOBUFS][BUFSIZE];
DWORD WINAPI WaveInThread (void *Arg)
{
MSG Msg;
int rv;
rv = SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL);
winexit_if(0 == rv, hWindow, "SetThreadPriority failed");
while (GetMessage (&Msg, NULL, 0, 0) == TRUE) {
if (MM_WIM_DATA == Msg.message) {
int rv = 0;
WAVEHDR *Hdr = (WAVEHDR *) Msg.lParam;
EnterCriticalSection(&remotefd_sem);
if (remotefd != INVALID_SOCKET) {
rv = sendto(remotefd, Hdr->lpData, sizeof(BufferIn[0]), 0,
(struct sockaddr *) &remote, sizeof(remote));
if (rv < 0) {
closesocket(remotefd);
remotefd = INVALID_SOCKET;
}
}
LeaveCriticalSection(&remotefd_sem);
waveInAddBuffer(hWaveIn, Hdr, sizeof(*Hdr));
if (rv < 0) MessageBox(hWindow, "sendto failed", "WARNING", MB_OK);
}
}
return 0;
}
BOOL CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG: {
WSADATA wsaData;
int rv;
int i;
WAVEFORMATEX waveform;
HANDLE WaveInThreadHandle;
DWORD WaveInThreadId;
hWindow = hWnd;
rv = WSAStartup(MAKEWORD(2, 2), &wsaData);
winexit_if(rv != 0, hWnd, "WSAStartup failed");
waveform.nChannels = AUDIOCHANNELS;
waveform.wBitsPerSample = 8;
waveform.nAvgBytesPerSec = AUDIOSPEED * waveform.nChannels * waveform.wBitsPerSample / 8;
waveform.wFormatTag = AUDIOFORMAT;
waveform.nSamplesPerSec = AUDIOSPEED;
waveform.nBlockAlign = 1;
waveform.cbSize = 0;
WaveInThreadHandle = CreateThread(NULL, 0, WaveInThread, NULL, 0, &WaveInThreadId);
winexit_if(NULL == WaveInThreadHandle, hWnd, "CreateThread failed");
rv = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveform, (DWORD)WaveInThreadId,0,CALLBACK_THREAD);
winexit_if(rv != MMSYSERR_NOERROR, hWnd, "waveInOpen failed f");
for (i = 0; i < AUDIOBUFS; ++i) {
WaveHdrIn[i].lpData = BufferIn[i];
WaveHdrIn[i].dwBufferLength = sizeof(BufferIn[0]);
WaveHdrIn[i].dwBytesRecorded = 0;
WaveHdrIn[i].dwUser = 0;
WaveHdrIn[i].dwFlags = 0;
WaveHdrIn[i].dwLoops = 0;
WaveHdrIn[i].lpNext = NULL;
WaveHdrIn[i].reserved = 0;
waveInPrepareHeader(hWaveIn, WaveHdrIn + i, sizeof(WaveHdrIn[0]));
waveInAddBuffer(hWaveIn, WaveHdrIn + i, sizeof(WaveHdrIn[0]));
}
waveInStart(hWaveIn);
break;
}
How can i encode the firstly wave?
I would handle with the microphon stream as wave. Only one step befor i send it with a socket i would encode it to ogg.
I finde the Page of the Ogg speex Project, but i cant understand the message behind the libary and the project has not a board for questions.
http://www.speex.org/docs/api/speex-api-reference.pdf
PS. Sorry for my bad english.
modified on Monday, February 2, 2009 12:04 PM
|
|
|
|
|
Hello,
I was searching some articles about serial port communication in c++ and ran into this:
http://msdn.microsoft.com/en-us/library/ms810467.aspx[^].
This also includes a sample application, named MTTY.
From the abstract.txt of the application:
MTTTY was built and tested under Microsoft Windows(TM)
95 and Microsoft Windows NT 3.51 using Microsoft
Visual C/C++ version 2.0 and the combined Win32 SDK
for Windows 95 and Windows NT.
Finally, my question to you is how to create/convert the MTTY project into a vs 2005/2008 project(I reckon that simply adding the headers,resources and sources won't do the job). And I also wanted to know if this application will run properly on Windows Xp(although it belongs to windows nt family, the code dates back to '95). Sorry for the dumb questions, just beginning to read about this. Thank you!
|
|
|
|
|
I don't see any problems with the code at a quick glance - it all looks like classic Win32 stuff. If it worked on NT3.51, it should be fine and dandy under XP.
I'd create a Hello World windows (no MFC) project, and just start chucking the code in there.
Alternatively, read the excellent serial primer by Flounder, and make your own code using that as a serial core.
http://www.flounder.com/serial.htm[^]
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi All,
When I clickoon system tray icon first time menu works fine , but second time I am getting error like this ;
"Debug assertion failed!
Program: ...
File: F:\rtm\vctools\vc7libs\ship\atlmfc\winmenu.cpp
line 84
retry abort "
code is goes like:
LRESULT CDialogOnTopDlg::onTrayNotify(WPARAM wParam,LPARAM lParam)
{
UINT uMsg = (UINT) lParam;
switch (uMsg )
{
case WM_RBUTTONDOWN:
m_TrayMenu.LoadMenu(IDR_MENU1); // second time crashing here
CPoint pt;
GetCursorPos(&pt);
m_TrayMenu.GetSubMenu(0)->TrackPopupMenu(0,pt.x,pt.y,this);
break;
}
return TRUE;
}
Plz tell me wot could be possible causes.
|
|
|
|
|
My guess would be that you already have that menu loaded and you try to load it again using the same CMenu, either load it once or delete/destroy it before you try to load it again.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
yes you r correct, actully i am using same menu for right click on tray icon and right click on dialog box (anywhere on dialog box),
so plz tell me hadnle same menu for these two things? how to destroy/delete after work os done?
|
|
|
|
|
Well, i think you can do generally 2 things:
1. Load your menu only once and keep it around until your program exits (for example you can load it in the OnInitDialog of your dialog)
2. Load, use and destroy it "on sight", for example, you can use TrackPopupMenuEx[^] with TPM_RETURNCMD, if you do this, when the TrackPopupMenuEx call finishes you will get the command back from the call telling you what the user clicked on (or 0 if he dismissed the menu) and then you can use DestroyMenu[^] to destroy it. Of course doing so you will no longer need your CMenu to hang around so you can make it a local variable and then it will destroy the menu in its destructor when your method exits.
Judging by what i have seen of your code i guess for you the first aproach could be better.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I'm certain code-o-mat is correct in his answer to you.
But you really should have used the debugger to see the actual ASSERT line - that will give you lots of information you need to fix your own problem. I/we don;t mind helping - but you are much better learning debugging skills to find the issue out your self.
I bet the ASSERT line was something like:
BOOL CMenu::LoadMenu (UINT nBlah)
{
ASSERT (m_hMenu == NULL);
which would have told you what your problem was.
And that's more than half the battle of solving the problem.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
crazy_sam wrote: m_TrayMenu.LoadMenu(IDR_MENU1); // second time crashing here
Make m_TrayMenu local to the OnTrayNotify() method.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I am using MFC picture control for displaying bmps on property dialog boxes. So I added picture contrl from the tools and changed the type to bitmap. Then selected a bmp resource to be loaded into the control. At design time the bmp is visible but at run time its not. I have done this before but the project used a MBCS. Now its Unicode.
Does that matter? If not what might be the problem?
TIA
|
|
|
|
|