|
<code>
char grid[8][8] = {0};
int i, h = 0;
for (i = 0; i < 9; i++)
{
for (h = 0; h < 9; h++)
{
grid[i][h] = '-';
}
}
</code>
|
|
|
|
|
That script keeps comming up with an error saying
array.exe has encountered a problem and needs to close.
|
|
|
|
|
Has anyone experienced a MFC Dialog application hanging and become non responsive when using GetSaveFileName? You can get the same problem when using CFileDialog since it calls GetSaveFileName. If you had this problem how did you correct it?
|
|
|
|
|
Do you have a code snippet that exhibits the problem?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hey all.
I'm wondering what the best way is to just completely end your program. I am building an auto-update-from-the-internet feature in one of my test programs (it's a school project).
What I want to do, is download the file, execute the file, and exit the program as soon as I execute the file.
Currently, I have this working fine. The way that I am "quickly ending" my main program, is right after I do the shell execute functions to call the setup.exe program, I am doing "OnOK();". That kills my program immediately ... which is perfect because just as the program ends the setup program is beginning to run.
I'm just wanting to make SURE that this is the right way to do it. I don't have any "cleanup" to do (ie, write contents to disk ,etc...) just exit out of the program.
BTW: I have tried using "DestroyWindow();" as well, and that seems to work just fine too. Just want to do it the right way.
Thanks
|
|
|
|
|
There are multiple ways to end a program.
-If you are using a dialog-based solution, calling 'EndDialog' of the dialog class will do.
-If you have an SDI/MDI application, using 'PostQuitMessage' on the main window class will do.
-If you have a standard Win32 application, just make it's WinMain function to return some value.
Basically, after you've done any clean-up such as resource-freeing or reserved memory freeing, any method to end your application is just as fine.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I am using Win32SDK.
What I want to do is to pass a BSTR from a ATL DLL to a Client? Now since Interface method can return only HRESULT. I will store the values in a Global Variable and use it in the client. Is there in Flaw on Design? I need feedback.
|
|
|
|
|
you can use
yourMethod([out,retval]BSTR **str);
in VB u can use like this
string str = yourMethod()
Abhishek Srivastava
Software Engineer (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
The physical return value from an interface method is an HRESULT; however, you can also return a logical value if need be. For example in your coclass:
<code>
STDMETHODIMP InterfaceMethod1([out, retval]BSTR* pBSTR);
STDMETHODIMP YourCoClass::InterfaceMethod1(BSTR* pBSTR)
{
*pBSTR = SysAllocString(OLESTR("Hello World!!"));
return S_OK;
}
</code>
Your client will need to call SysFreeString(BSTR bstr) when finished with the BSTR.
JS
|
|
|
|
|
Could anyone pls tell me how to programmatically (VC++/VB6) get the CPU time & mem usage of a process, given the process name(or PID), under WIN2K?
Th...x
|
|
|
|
|
for mem usage,refer to GetProcessMemoryInfo
for cpu time, refer to GetProcessTimes
and you can also get all information of processes by using Performance Montoring Functions: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/performance_data.asp
but i don't like to use them,because this library uses much system resources, even a simplest program using this library will have at least 7 threads and 5K memory usage.
|
|
|
|
|
This article might be of some help. The Heap32First() /Heap32Next() functions can be used to walk the heap of a process, examining each of the blocks and summing their size if necessary. I've not actually tried this, however. See GetProcessMemoryInfo() .
Also look at this article. It does not report numbers like Task Manager does, however.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I created an SDI MFC app, and print preview shows the correct range of pages, but when actually printing (on any printer) it will print a trailing blank page. I have overloaded the functions OnPrint, OnBeginPrinting, OnPreparePrinting (for a CRichEditView derived class). Ive tried calculating the value for SetMaxPage() using char heights and lines per document, etc. but it never comes out right. Any suggestions as to how to get the framework to stop printing the extra blank page every time?
nak
|
|
|
|
|
Have you tried different printers?
|
|
|
|
|
Are your calculations based on the display DC or the printer DC? There is a slight difference. Mainly in that the actual paper size is not the "printable area". Printers have a non-printable margin area (on laserjets, usually 1/4 inch) that is not addressable. So, your 8 1/2 x 11 paper is really 8 x 10 1/2 printer addressable. See GetDeviceCaps with the opcodes of PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, etc.
onwards and upwards...
|
|
|
|
|
Yes, Im using DEVICECAPS and other methods to calc the drawable area. The extra page does not print my headers and footers on it, so it must not be calling OnPrint for the last blank page. As per the other response I have tried it on different printers and different documents and it always prints the extra page. I was wondering if theres any way to override OnEndPrint or some "cheap" way to just stop it from spitting out that extra page. (Could the printer be receiving some line feed or something after the actual document that makes it print a blank page?)
|
|
|
|
|
Yes it seems that the printer gets some extra line feed or something like that. If the print preview is ok, it seems to be a hardware problem. Did you try your program on an other PC?
You may also check how often your OnPrint method is called during printing.
|
|
|
|
|
Actually its nothing like that. If you research the MFC underlying infrastructure, the CPrintInfo object has default min, max page values of 1 & 0xFFFF respectively. Thus when printing it will print to those pages, until it encounters a page with no data. As far as Ive found the only way to get rid of this is to SetMaxPage to the correct number of pages. But the textmetrics & sizes that some Printer DeviceContexts return to you arent correct, so Im still having problems determining exactly how to calculate this. Also strangely, in my font, the boldface char's seem to take up barely more space than the regular ones. Im still working on this problem, so Im not sure what the solution is yet
|
|
|
|
|
Not sure if this applies here, as I don't use VC++ but anyhow...
I'm trying to use GDI+, and I've tried to apply the tips from the Starting with GDI+ article with my Dev-C++ compiler, but I get many errors on the file "GdiPlusEnums.h" like "enumerator value for" and "conversion to". Any advice? I'm using an example from the PSDK documentation, so I'm pretty sure nothing is wrong with my code...
|
|
|
|
|
using the visual c++ 6.0 & MFC library I created a propert pages resources and added them to the property sheet object CPropertySheet what happens is that the property sheet will be created as large as the largest property page what I need to do is to make this propertysheet fixed in size and make the large pages have a vertical scroll bar to fit in the propertysheet
so if the property page has many edit boxes we create a scrollable frame around those edit boxes so not all of them have to be shown at the same time.so how we can acheive this and do we have to do it with the resource editer or programmaticlly.
thanks in advance
alhaneen
|
|
|
|
|
Hello All,
I wasnt sure if this should go in the C++ or VB Board but I think it relates more to C++.
Anyway. I have been writing an app which does masses of processing using SQL. The problem is that VB is to slow.
I want to be able to write a DLL that can get the data from the MySQL database and put it in the DataGrid on the VB Form.
Is this possible? Easy to be done?
I have already optimised one piece of code someone else wrote. That took 18 hours to do the processing. The C++ dll I wrote did it in 30 seconds. I don't believe ill get this kind of speed increase with the section I need the latest DLL for because it only takes 10 seconds now anyway. But it is something that will be accessed a lot and regulary so 10 seconds is a lot of wasted time in a day.
What I really want is to be able to have every single bit of processing done by C++ and only VB used for the interface.
Any help would be greatly appreciated.
Thanks.
|
|
|
|
|
It is possible, but might not be easy.
Create a C++ DLL that contains an ATL or a COM object. Make this object to implement the C++ or MFC database support. Then use this DLL from VB. You must use COM because C++ and Basic are not directly compatible.
The easiest way for sure is to build the entire application in VC++, though...
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I'm trying to write in a file in my .cpp code:
I have a TCHAR variable szText and it should be a string so I could write fprintf( fichero, "%s\n", szText); How could I convert my TCHAR in a string?
Thank you very much!!!!
|
|
|
|
|
Hello,
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvc/html/msdn_mbcssg.asp
With Regards,
R.Selvam
|
|
|
|
|
If szText is a TCHAR , the correct syntax would be:
fprintf( fichero, "%c\n", szText);
I assume, however, that you meant that szText was a TCHAR* . Correct? If so, your fprintf() statement is correct.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|