|
Hi,
I have a program developed on Windows 2000 with the following properties:
1. It is an MFC Appwizard generated MDI application
2. Links to a COM server that I wrote
3. Links to 2 ActiveX Controls that I use for displaying graphics
4. Links to 2 dll's that basically have functions that communicate with the serial port
5. Is multi-threaded, I create my threads using the Win32 API ::CreateThread().
I have tested this program on Windows XP and Windows 2000 and it runs on these platforms without a hitch. However, when I use this program on Windows 98, my program crashes in many places. I deploy my program using Windows Installer so that my COM Server and ActiveX Controls are automatically registered for me, and on Win98 it seems that the program can successfully talk to the COM Server and use the ActiveX Controls.
I am wondering if anyone has experience developing applications that work with all of XP,2k and 98 and can tell me what would cause my program to crash on Win98? Will a re-compile with optimizations on a Windows 98 machine fix it? Or will it have no effect at all? I would also like to point out that the Windows 98 machine is slower and has less ram. Sometimes I get the out of hdd space warning too. Could this cause my program to crash?
Thanks in advance!
|
|
|
|
|
Things that come to mind from your description:
* Don't use CreateThread() to create threads, use AfxBeginThread() if the thread contains MFC code, or _beginthreadex() otherwise.
* Make sure your graphics drawing code cleans up GDI objects properly everywhere. Win 9x has 16-bit limitations in GDI, it's very easy to exhaust an internal 64K heap if you leak GDI objects (pens, brushes, etc).
* Does your serial port code work on 9x in the first place? Hardware access is radically different between 9x and NT.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
|
|
|
|
|
Thanks Michael, these are all very helpful hints that I have read about at many places but never followed because my code seemed to work in 2k I guess I should really look into the docs more closely and then go over all my code that doesn't behave.
Most of my graphics drawing code is in my ActiveX controls. They do actually store graphic objects to speed up draw times I guess that may be why its causing crashes.
I am using CreateFile and ReadFile functions to get at the serial port. I can't seem to find information about how hardware access is radically different between 9x and the newer 2k, but this will bump me in the right direction for further investigation.
Thanks again!
|
|
|
|
|
How can I enable the cut/copy/paste function in a "Form View"?
If I put a text box (edit control) in a dialog box with a MFC Dialog based application, the cut/paste functions work automatically with the Ctrl-X and Ctrl-V keys without any additional codes.
But if I were to do the same with a form view, i.e., using CFormView as the base class in a MFC SDI application, the cut/paste function is deactivated by default. How can I enable the functions?
Interestingly, I can get the functions to work simply by deleting all the associate accelerator keys. However, this is not the right approach as the menu functions remain grayed out.
|
|
|
|
|
Under link below to 'my articles' see the 'lockable edit and combobox controls' article. The article is meant to demonstrate something else, but I also implement Ctrl+C,Ctrl+V functionality in the classes.
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
My understading of your approach is to derive a new class, CLockEdit, from CEdit and then use PreTranslateMessage to catch messages before the functions are executed. But is it necessary to create a new class just for this?
All I wanted to do is to turn on the cut/copy/paste function that is already there. As I had mentioned, the function can be enabled simply by deleting the Ctrl+X/C/V accelerators. My guess is that since I did not build any event handler for the accelerators, default handlers are used, which turns the function on.
If my guess is correct, shouldn't I be able to enable the functions via accelerators or menu functions, without the need of a new edit class?
|
|
|
|
|
h.lee wrote:
shouldn't I be able to enable the functions via accelerators or menu functions, without the need of a new edit class?
Probably so, but I don't know how, myself. This class I made was mainly to let edit controls be disabled without being grayed out. I was just trying to provide any help I could.
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Thanks for the help. As a newbie I really appreciate any help I can get. One day hopefully I can be like you and a bunch of others in this forum to offer helps to others.
For now, someone please help!
|
|
|
|
|
CBrush brush;
brush.CreateSolidBrush(RGB(0,0,255)); // Blue
CRect rc = CRect(CPoint(100,0), CPoint(200,100));
//Blue Rectangle
dc.SelectObject(&brush);
dc.Rectangle(CRect(CPoint(0,0), CPoint(100, 100)));
//Yellow Rectangle
dc.DrawDragRect(&rc, bdry, NULL, bdry, &brush, NULL);
|
|
|
|
|
Hi,
I'm using Microsoft Visual Studio .Net 2003. I created a class and wrote a constructor that took three parameters:
int,
unsigned char,
int
Then, realizing that when declaring a class as a managed type (__gc) that I can't have unsigned data types, I went back to my constructor and I changed the data types to:
(Keep in mind, I declared all the appropriate #using <mscorlib.dll> #using <system.dll> using namespace System; etc)
System::Int32,
System::Byte,
System::Int32
I did a "Clean Solution" and then a Build Solution and yet, when I try to create an instance of my object:
ConsumptionManager * consumptionManager = new ConsumptionManager(1, 2, 3);
It still expects me to pass the old parameter data types. How can I get the compiler to pick up the new parameter data types?
Thanks
PPM
|
|
|
|
|
I am trying to zoom an excel sheet to 75% from C++, using visual studio .net 2003. I have an mfc application and have imported objects to access an excel sheet. I can zoom the printed version out to 75% but I can't get the magnification to 75%. Anyone know any way to to this?
|
|
|
|
|
I am working on a server application that spawns a new thread for each user request. Then the number of requests gets over 20 or so there is a noticable slowdown in performance. BUT!!! the CPU doesn't show a spike.
I am attributing this to having too many things going on at the same time (imagine printing from 20 applications at once) Does anyone know which of the many counters I can look at to show the true load?
The threads are spread over many processes, so no individual process is getting enough time to show up on the performance monitor.
MFC 6.0 SP5
IIS communicating with a "Master program" using winsock
Master program communicates with surrogates via windows messages (WM_COPYDATA...)
Thanks,
Brad Bruce
|
|
|
|
|
One thing you might be able to do is look at the % Processor Time counter of the Idle instance. If you see this number drop, you know that the CPU is busy doing something else.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Are you sure it is CPU? Perhaps your network is overloaded? Perhaps you are loading more data off the drive than it can transfer. At one time (back was a 486 was hot) this would commonly indicate you were out of memory and swapping (not so much an issue now, but it might be in your particular case).
My guess is network, get a good network card on a good switch. (Cheap gigabit ethernet cards often are barely faster than 100megabit in real world abilities)
In short, do not rule anything out. These days CPUs are rarely the bottleneck.
|
|
|
|
|
Network was the first thing looked at (The experts say we're good there)
Tonight I was able to run one of the programs in isolation. It used 50% of the CPU by itself.
Common sense says that if you're running 4 instances of the same application you're using 200% of the CPU etc.
I was able to watch CPU time go up as these processes were running. Unfortunatly when it reaches a "breaking" point the CPU meter drops down to 12-15% utilization even with all of the processes running.
"I'm so confused!!!!"
Thanks for the input though (I might have to personally check the network tomorrow!!!!!)
|
|
|
|
|
Well first you need to profile your code and see where and why it is taking so much CPU time. Often a small change can make a major difference. If you can get the amount of CPU you use down, that can mean a lot. If you can't get your CPU use down, you need to add more CPUs to the problem.
As for why you are seeing problems, I can only guess. Some things it could be:
Each time the OS switches processes you trash the CPU cahce, and it is taking that long to update because your processes aren't very cache friendly anyway. In this case if you can change how your look at data it might help. (ex: when looking at a 2d array perhaps you should loop on elements in a different order) This is a real problem, but it very complex.
Locks could easilly be a problem. The classic one thread grabs lock A, then lock B, while the other grabs lock B, then A - except it happens at the same time so both processes are hung waiting on the other. That you complete the tasks only suggests you have timeouts on your locks, so if you don't get a lock quickly you release all locks until you can get the others. This would explain your situation.
You said network was ruled out, but have you ruled out swaping? Maybe you just need to add more RAM.
If you are dealing with a database, hire an expert in that database to optimise your queries. You might be able to get some major improvements with some fancy work here.
My guess is that the code profiler will give you the most useful information.
|
|
|
|
|
Each request is doing exactly what it should. These request frequently create files in the 512K to 1Meg range. (A LOT of data) They are reading from the database as they should.
The problem is that the CPU meter reads wrong. It's as if the process monitor doesn't see the work, because so little gets done in each time-slice.
I was just wondering if there was a counter that showed true CPU utilization.
|
|
|
|
|
Does anyone know what is the meaning of this warning? It occurs when I select a menu item in my project to open a modeless dialog. I see this warning in the debug output window only. The ID that it refers to is the resource ID for my modeless dialog. Thanks.
|
|
|
|
|
Check out both of the following:
line 1891 of ctlcore.cpp
line 1479 of winfrm.cpp
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
If you have not supplied a prompt string in the resource editor for your menu, you will get this message.
Use the resource editor, highlight your menu item and press ALT+Enter to see the properties.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Yes, that fixed the problem. Thank you very much!!
|
|
|
|
|
Hey,
I'm working on a snippet intented to grab a specific block of the heap of a running application.
To do this, I'm using the following steps:
- Retrieving the application's process ID
- Retrieving the address and the size of the block to be read
- Reading the block...
For this purpose I use the ToolHelp32-API of Windows. My problem is that the 3rd step currently refuses to work. I obtain a correct processID, I get (likely correct) address and size of the block, but both functions Toolhelp32ReadProcessMemory() and ReadProcessMemory() solely return FALSE.
I would be glad, if someone of you has an idea what this could be due to... Thanks in advance,
Tobias
|
|
|
|
|
When ReadProcessMemory() returns FALSE, what does GetLastError() return?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I solved the problem. The cause was, that (for what reason soever) the last 8 bytes of the heap block were locked for reading. If I exclude those bits, the function works as expected.
Thanks for your post, though.
Tobias
|
|
|
|
|
Hello,
(I thought I should post this in the Visual Studio IDE forum but it says not to post any programming questions there)
I am trying to move from VS 6 to VS 7 (aka .NET, aka 2003). The class wizard seems to be gone and instead replaced by options to add methods/variables/properties etc. How does one remove/delete methods/variables/properties without manually editing the code now that the wizard is gone.
Secondly and more importantly, in VS 6 you could create a new project and select from the wizard the project's type to be MFC ActiveX Control. The wizard then allowed you to set the number of ActiveX controls the project should have. The problem with this was that once you set the number of controls, you could not later add more controls to that project (or is there?). The only way to do this as far as I know is to RESTART a new MFC ActiveX control project setting the control number higher and importing all the previous files again.
In Visual Studio .NET when I create a new project of type MFC ActiveX Control, I no longer have the option to enter the number of controls the project should contain. As a result that project can only have one control. This raises the questions on whether this means there is now a method to add more controls to the project at a later stage instead of specifying such a number from the very begining and being stuck with it. Is this the case? How can I set the number of controls an ActiveX Control project has in Visual Studio .NET?
Where have all the wizards gone?
Thanks,
Aristotel
|
|
|
|