|
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
|
|
|
|
|
greekgoddj wrote:
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.
The Class Wizard is gone. You can add new member methods/variables/properties by using the menu, but you must delete them manually. There's no auto-deleting option built-in. The new way to override virtual methods (such as adding Win32 message handlers) is to click on a class name in Class View, then use the Properties box on the right. I think this was a good introduction, because the code Class Wizard used to generate looked ugly as hell. You can further enhance your productivity by installing a third-party tool such as Visual Assist.
greekgoddj wrote:
-- Is this the case? How can I set the number of controls an ActiveX Control project has in Visual Studio .NET?
Your approach is wrong. To create a multi-control ActiveX component, create an ATL Project (wizard) first. Call it 'My Controls', for example. Then go to Class View, choose 'Add Class' and select 'ATL Control' as type. This adds a new ATL ActiveX control into the project. Another method is to create an MFC ActiveX Control, then add ATL support and add ATL Controls like above.
The MFC Class Library has been merged with ATL, creating the ATL/MFC Library which currently exists in VS 2003. This is visible through the documentation, and the introduction of classes like CStringT. It is _strongly_ encouraged to use pure ATL in creating ActiveX Controls. That is what ATL was built for: ActiveX Template Library.
greekgoddj wrote:
Where have all the wizards gone?
You know how wizards are: short-tempered and quick to anger. It seems they've decided to take a leave. Microsoft became with a whole new approach to the wizard theme, replacing them with scripted dialogs that only generate pure code and cease to exist after they've been ran. This removes things like Class Wizard database files (which were always corrupt) and the ugly-looking defines and insertion point markings with triple-backslashes. I think it was a good thing. The code's clear, good-looking and easy to follow. It does introduce some more manual work, but using the mouse and Delete, I think it's pretty easy to remove unneeded variables/methods.
Then about the versioning. Visual Studio version 6 was version 6. Version 7 is .Net 2002 and 7.1 is .Net 2003. Version 8 will be 2005, when it's released.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
Thanks!
I have gone ahead and started moving my MFC based ActiveX Control projects to ATL ActiveX projects with ATL controls supporting MFC.
So far so good, however i do have the following problem with using ATL.
In the MFC only version I was calling
[code]
Invalidate()
[/code]
everytime there were changes made to values that required for the display to be redrawn. Calling the same function in the ATL version of the ActiveX Control, gives me an assertion message.
The part of the code the causes this message is
[code]
BOOL Invalidate(BOOL bErase = TRUE) throw()
{
ATLASSERT(::IsWindow(m_hWnd));
return ::InvalidateRect(m_hWnd, NULL, bErase);
}
[/code]
I have not worked with ATL before. Has anybody come accross this before, and how does one tell the ActiveX control that it needs to update the display/graphics?
Thanks in advance!
Aristotel
|
|
|
|
|
Great,
afte loosing 2 hours or so on this matter, AFTER posting this thread, I found the answer. Well for those who need it in the future the answer is:
[code]
FireViewChange()
[/code]
Ciao
|
|
|
|
|
If it causes an assertion, the reason is clear. Apparently you're calling Invalidate for the CWindow-class. If this class's m_hWnd member is not a valid window, it will cause an assertion.
The most common reason for this is that your CWindow class is not properly constructed, initialized and created. Perhaps you're calling Invalidate too early ? To avoid this, add a conditional sentence in front of your Invalidate call that will check if the window in question is valid. This way, Invalidate will only be called on valid windows and the assertion will never fire.
Otherwise, ATL has nothing in special compared to MFC or Win32. The CWindow::Invalidate will call InvalidateRect Win32 function to do it's task.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
i have a program that it read dxf. but my program only read simle's dxf.
hope have i that friend help to you . my program project is send to your friend.please your email to me
yangxjn@hotmail.com
yangxjn@163.com
MSN:yangxjn@hotmail.com
|
|
|
|
|
What exactly are you asking (or telling us) here?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
I am currently trying to communicate via the COM port with a device of mine. For now, the device just echoes immediatly the character it receives.
PC Platform: WinXP Pro, MS VStudio 6.0, VC++
I read some articles from the site (really helpful, like to thank konchat, Ashish Dar - good articles for head start in Win API serial port programming) and tried to send some chars through the serial port and subsequently reading the char return by the device. (note: already tried the device with hyperterminal and it echoes well, no hang-ups or smth).
I used 8n1, non-overlapped mode for the serial port.
at first it seemed the program works, when trying to send (e.g. characters 65 to 90 ASCII) by the 24 char (Y) the program doesn't receive characters any more (they still get to the device as it shows me which chars arrived by flashing LED-s connected to a register).
Even stranger, if a run the program.. stop it, say it.. after the 10 sent character and run it again, exactly at the 14 char it will stop receiving data. (10+14= ??!!! exactly, 24).
Is there something i am doing wrong?. Here the code that does the sending:
<br />
<br />
DCB dcb = {0};<br />
dcb.DCBlength = sizeof(DCB);<br />
DWORD dwBaudRate=9600;<br />
BYTE byStopBits=1,<br />
byByteSize=8, <br />
byParity=NOPARITY;<br />
COMMTIMEOUTS cto;<br />
const HANDLE hPort = CreateFile( portname,<br />
GENERIC_READ | GENERIC_WRITE, <br />
0, <br />
0, <br />
OPEN_EXISTING, <br />
0,
0);<br />
<br />
if (hPort == INVALID_HANDLE_VALUE)<br />
AfxMessageBox("Could not open "+portname+" port.");<br />
else<br />
{<br />
cto.ReadIntervalTimeout = 1000;<br />
cto.ReadTotalTimeoutConstant = 1000;<br />
cto.ReadTotalTimeoutMultiplier = 1000;<br />
cto.WriteTotalTimeoutConstant = 1000;<br />
cto.WriteTotalTimeoutMultiplier = 1000;<br />
SetCommTimeouts(hPort, &cto);<br />
int index=1;<br />
for (int k=0; k < 10; k++)<br />
for (int i=65; i< 91; i++)<br />
{<br />
char outb[1],inb[1];<br />
DWORD sent,read;<br />
outb[0]=(i);<br />
if (WriteFile(hPort,outb,1,&sent,NULL)==0)<br />
{<br />
AfxMessageBox("Error Writing to "+portname+" port.");<br />
nRetCode=1;<br />
}<br />
std::cout << index << ": sent=" << char(outb[0]) << " ";<br />
index++;<br />
inb[0]=0;<br />
if (ReadFile(hPort, inb, 1, &read, NULL)==0)<br />
{<br />
AfxMessageBox("Error reading from "+portname+" port.");<br />
nRetCode=1;<br />
}<br />
std::cout << "rcvd=" << char(inb[0]);<br />
if (outb[0]==inb[0]) <br />
std::cout << " ... OK";<br />
else<br />
std::cout << " ... NOK";<br />
std::cout << std::endl << std::endl;<br />
PurgeComm(hPort, PURGE_TXABORT | PURGE_RXABORT | <br />
PURGE_TXCLEAR | PURGE_RXCLEAR);<br />
}
<br />
}
if(CloseHandle(hPort) == 0)<br />
{<br />
AfxMessageBox("Error closing "+portname+" port.");<br />
nRetCode=1;<br />
}<br />
std::cout << "Port " << portname << " closed." << std::endl << std::endl;<br />
Any ideas, anyone?
Looking forward to your replies.
Found the bug. If anyone steps across this one in future: when using Win API for Serial Port access, always set the DCB Structure or else the code will work only partially (only God and Bill Gates know why but... who am I to judge :P ). I used a system call "system('mode COM1..... ');" to set the com parameters and the API doesn't seem to cope very well with that.
Anyways... Happy coding
Nik0n
|
|
|
|
|
|
Hi, Thx for the reply.
No handshake for now: no hardware rts/cts nor software xon/xoff. just wanna see it run for a
while, no packet dropping, no hang-ups.
It's just a preliminary test before writing the software for the device.
Nik0n
|
|
|
|
|