|
OK, Mike. The extern keyword takes care of the problems with the template parameters.
Thanks for the tip
Aaron
|
|
|
|
|
I have written an MDI application with visual C++ 6, overrided
the functions : OnSaveDocument and OnOpenDocument to use my own serialization and filters.
The debug version works correctly, and I have a serious problem with my release version.
When I save my document, I quit the application without any prompt (The document is all the same saved...)
Problem of leak of memory, or initialization ,...?
How can do to find out error(s) and what tool can use ?
Thank in advance for your help.
Leo.
|
|
|
|
|
Problem of leak of memory, or initialization ,...?
This may be an initialization problem - in the release build local variables of primitive types are not initialized.
Also, you may have vital code inside ASSERTs - in the release build the code disappears; if this is the case, use VERIFY instead.
How can do to find out error(s) and what tool can use ?
BoundsChecker (www.numega.com) or Purify (www.rational.com). Note that you'll have to create new configuration based on Release, but with debug info on.
If your OnSave/OnOpenDocument code isn't very long, post it here. You can consider CodeProject forum to be another semi-automatic diagnostic tool
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello folks,
I have a question with regards to printing in Win32 to printers who's name exceed the DEVMODE.dmDeviceName[32] limit.
In our product, we allow the user to set a default printer. We populate the possible printer list by using the following code:
flags = PRINTER_ENUM_LOCAL;
if ( IsWindows95 () )
level = 5;
else
flags |= PRINTER_ENUM_CONNECTIONS;
pbuf = (PBYTE) NULL;
EnumPrinters ( flags, NULL, level, pbuf, 0, &size, &num );
if ( asize > 0 )
{
pbuf = (PBYTE ) calloc ( size, 1 );
if ( pbuf == (PBYTE) NULL )
goto exit_func;
size = num = 0;
EnumPrinters ( flags, NULL, level, pbuf, asize, &size, &num );
if ( size == 0 || num == 0 )
goto exit_func;
if ( IsWindows95 ( ) )
pinf5 = (PRINTER_INFO_5 *) pbuf;
else
pinf4 = (PRINTER_INFO_4 *) pbuf;
retval = TRUE;
/* Now fill the listbox with the printers available. */
SendDlgItemMessage ( hwnd, id, CB_RESETCONTENT, 0, 0 );
for ( i = 0; i < num; i++ )
{
if ( IsWindows95 () )
{
SendDlgItemMessage ( hwnd, id, CB_ADDSTRING,
(WPARAM) 0, (LPARAM) pinf5->pPrinterName );
pinf5++; /* Next structure */
}
else
{
SendDlgItemMessage ( hwnd, id, CB_ADDSTRING,
(WPARAM) 0, (LPARAM) pinf4->pPrinterName );
pinf4++; /* Next structure */
}
}
No problems here, we simply store the pPrinterName in one of our variables such that when the time comes to print, we build the DEVMODE structure, then create our dc.
The problem comes when the user selects a printer that exceeds the 32 character maximum, (ie, network printer), where the name could be "\\nt200\FOO\FOO\PRINTER1010101". If the variable we stored was something like "\\nt200\laser1", everything would be fine, the document would print without any problems.
In the MSDN documentation it notes the following on the dmDeviceName variable:
Specifies the the "friendly" name of the printer; for example, "PCL/HP LaserJet" in the case of PCL/HP LaserJet®. This string is unique among device drivers. Note that this name may be truncated to fit in the dmDeviceName array.
How does Windows handle the case where the printer name exceeds the 32character max? Is there a field I could put the server name?
Mike.
|
|
|
|
|
There's an extenssion to win32API that comes with Win2000/XP
that allows to impose some restrictions on single process or
process group. The flags that are used to define constraints
allow to achieve a lot , but I couldnt find how to force
process /group of processes to use not more than some amount
of procesor computing power, measured in % (percentage).
For example: I want a media player which decodes some
video file (ie divx format) to use not more than 50% of
computing power of my CPU. If the program wants to consume more
CPU procesing power (than the specyfied amount)it would simply not receive it. When viewing the performance tab of task manager , the upper graf (of the cpu) shouldn't exceed 50% (provided that no other applications use processor).
I know that it is possible , since the IIS (that comes with
Win2000) allows to specify whether or not to use 'process throttling' , and to specify how many CPU computing power a web application (running some executable code / scripts) within the server may consume
Thanx in advance
Michal Januszczyk
Michal Januszczyk
|
|
|
|
|
I have created an MFC Extension DLL with the intention to export a FormView. I edited my resource.h file to force the Resource Objects to start at 9000. This allowed my form view to be created with the correct resource. Is this OK or is there a better way to export the resources that go along with my exported FormView?
|
|
|
|
|
|
We are using MS Access Database. Is it possible to execute a macro in the access database from VC++ program. My macro consists of several sqls. I understand you could do CDaoQueryDef to execute sqls, but my macro also has a transfer text that imports a txt file and creates a table in the database. I want to know if it is possible to directly execute the macro from the program. Any suggestions or ideas would be greatly appreciated.
Thanks,
|
|
|
|
|
Is Imposible, to do that, but you can try to execute the macro from a Query into the Access database, and in that case, you can execute the query...
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Are you saying that I create a Query in Access database to execute the Macro. If that is what you are saying, how do I do that. When I create a new query within access database, it doesn't even give me an option to include a macro. Please advise.
Thanks,
|
|
|
|
|
Yes, I don't Know How you can execute a Macro from a Query, but is true that you can not execute a Access Macro from VC++. I am not an expert in Access, but I think that you need to execute the macro from the Query.
But at this moment I have an Idea: You can execute the macro with OleAutomation. I think that this last one is the best...
Cheers!!!
Carlos Antollini.
|
|
|
|
|
I don't know a whole lot about OleAutomation. Would you direct me to some place where I can find sample code.
Thanks,
|
|
|
|
|
You can see into the MSDN
Q192348. This Article, have a sample of AleAutomation with Excel
You can make the same with Access.
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Here's what you can do from VB
Private Sub Form_Load()
Access.OpenCurrentDatabase ("f:\Dev\test.mdb")
Access.DoCmd.RunMacro "ExportAll"
Unload Form1
End Sub
|
|
|
|
|
If I were to use VBScript would the code be the same as above.
Thanks,
|
|
|
|
|
As Carlos has already pointed out you have to use OLE automation to do this. It's very important to keep in mind that MS Access is *not* a database - it's an application that implements an user interface to the Jet database. You can use the Jet database from VC++ through any of the technologies in MDAC - DAO, OLE DB, ADO, ODBC. But MS Access implements a number of features that makes your everyday use of the Jet database easier. This includes a query designer, a report generator and a macro facility. However, these functionalities belong to the Access application and *not* to the Jet database. AFAIK Access stores the these things in the Jet database as BLOB fields, but they are proprietary to Access and hence not accessible through the Jet connectivities.
But as you can with all the MS Office applications you can "remote control" Access through OLE automation. It does however require that the user has MS Access installed on the PC. The free Jet engine is not sufficient.
As Todd Smith has shown it is very easy to do automation from VB (ouch! I sad the word! I have to go and wash my mouth with soap;P )
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I'm trying to popup a window just above the system tray ( like Microsoft Messenger does). Is there a way of finding out the system tray position. The best I've found so far is the SPI_GETWORKAREA parameter but this gives me the work area and not the position of the system tray.
Any ideas,
Michael
|
|
|
|
|
Look the Function SHAppBarMessage
You can get the position of TaskBar. With that position you can put your Dialog over the TaskBar.
You can see if your taskbar, is at left, Rigth, Tip or Bottom of your Screen.
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
Hi,
I´m trying to change the bitmap image ( Shown in the right side) of a context menu, I have tried this, but don´t works, What I have made wrong ? ( _DeleteCommentBitmap is a member variable of the view, and it´s a CBitmap one)
pPopup->ModifyMenu( ID_WBS_POPUP_COMMENT, MF_BYCOMMAND, ID_WBS_POPUP_COMMENT,
&_DeleteCommentBitmap);
Thanks, Bye !
Braulio
|
|
|
|
|
Hello,
I have a dialog type app and I need to make my own Minimize button.. Does anyone have a sample of code that would allow someone to create their own minimize button?
Thanks,
Rob
|
|
|
|
|
Why do you need your own minimize button? Why not just capture the minimize button being clicked and do your own thing?
Michael
|
|
|
|
|
I have created a dialog type app that uses a bitmap for a background.. This allows me to create a non-rectangular dialog box (mine has rounded transparent corners and a nice skin/type look).. The problem is to do this I can't use a border on the dialog box nor can I use a title bar.. so I don't even have a minimize button on this dialog.. I need to make my own minimize button to minimize the app.
Thanks,
Rob
|
|
|
|
|
Okay. I see. Where do you want to put the minimize button? I assume you know how to minimize the window ( ShowWindow(SW_MINIMIZE) ).
Michael
|
|
|
|
|
I'm pretty new to programming and I don't even know where to start on the minimize process.. I want the app to minimize to the tray/system bar like most other apps do by default.. Minimizing the app by the system clock would be awesome but it would probably require a lot more code and I assume it would be much more difficult, so for the time being just minimizing to the tray/system bar would be fine.
Do you have sample code I could try?
Thanks for you help and fast responses!!!!
Rob
|
|
|
|
|
Never mind the CDialog::ShowWindow(SW_SHOWMINIMIZE); worked fine
Thanks!!
Rob
|
|
|
|