|
I have the following problem :
I have written a MDI Application opening and reading files of type *.myapp
I have made a file association with my application and when a user clicks a file with the extension *.myapp my application starts but does not load the file.
I know I have to read the parameters the shell passes to my program, but I do not know how. And I do not know for which event I should write a handler.
modified 9-Mar-17 17:23pm.
|
|
|
|
|
Daniel Kanev wrote:
I have written a MDI Application opening and reading files of type *.myapp
Did you use AppWizard for this?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
In visual studio .net ver 2003 in reguards to c++ my multiplication is messed up. I get a result of 0 when I try and multiply the following. What's wrong?
#include "stdafx.h"
#using <mscorlib.dll>
#include "math.h"
using namespace System;
int _tmain()
{
__int64 p;
p= 16 * 268435456;
Console::WriteLine(p);
return 0;
}
|
|
|
|
|
I assume that the WriteLine() method supports a __int64 type. What is the largest value (e.g., 231) that you can successfully send to WriteLine() ?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
The number I am multipling with 16 is the highest number for the output.
|
|
|
|
|
If 228 is the highest number for the output, what does outputting 228 + 1 produce? If that does not work, I would expect 232 to fail as well. Yes?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
The highest number I can multiply it to is 7 after that I get the error message:
warning C4307: '*' : integral constant overflow
|
|
|
|
|
That indicates that you are running into a signed/unsigned problem. What does this yield:
p = 8U * 268435456U;
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
|
What about:
unsigned __int64 p;
p = 16U * 268435456U;
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
|
The compiler is telling you exactly what's wrong "integral constant overflow". That expression overflows the capacity of an int . You need to specify that the constants are 64-bit int s:
p = 16I64 * 268435456I64;
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Thanks Mike. I was aware of L and U but did not know about the I64 modifier.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
That worked great. However is there a way I can use exponents with the 64-bit int's?
|
|
|
|
|
I'm sure there is something simple and obvious that I am missing here, maybe somebody can help me?
I have a toolbar that gets initialized from a toolbar resource (one big bitmap with all images in it).
The toolbar is customizable (using standard dialog), so that when the dialog is displayed, you get a list of all the buttons available on the left, and a list of all the buttons currently on the toolbar on the right.
The buttons on the left and right together are all of the buttons available in the toolbar resource bitmap.
In some cases, I would like to exclude some buttons in the toolbar resource bitmap from being displayed as available (i.e. remove them from the left list).
When the list is populated, you get messages that let you say whether the button is available, but the first time you say no, it stops asking about the remaining buttons.
Like I said, there must be something simple I am missing.
Thanks for you help!
- Sean
|
|
|
|
|
Sean McKinnon wrote:
In some cases, I would like to exclude some buttons in the toolbar resource bitmap from being displayed as available (i.e. remove them from the left list).
Wouldn't it be easier to just enable/diasble the buttons? If not, then you'll probably need to create multiple toolbars (one for each situation).
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
DavidCrow wrote:
Wouldn't it be easier to just enable/diasble the buttons? If not, then you'll probably need to create multiple toolbars (one for each situation).
Yes, it would be easier, and I do that in other circumstances.
My problem is that I have a single application that talks (serial or ethernet) to several different versions/types of hardware. The application automatically configures itself to the capabilities and resources of the attached hardware. (It is a user-interface for status monitoring and configuation of the hardware).
The application has always removed menu items for features that the attached hardware cannot support, and disabled menu items for features that the hardware could support, but that are not currently enabled. This works fine for menu items.
The toolbar used to be fixed (and only included items that were supported on all hardware platforms). Now, we've added customizable toolbars, so I now have buttons for features that may not be supported on various hardware platforms. I can (and do) still disable toolbar buttons for features that are supported but not enabled (and I also do this for toolbar buttons for features that are not supported at all, but would really prefer to hide/remove these buttons like I do for menu items).
Creating multiple toolbars for all the possible configurations would be a nightmare for sure.
I guess this isn't as easy as I had hoped for?
Thanks - Sean
|
|
|
|
|
If you are using MFC:
CToolBar tb;
tb.GetToolBarCtrl().HideButton(ID_CONNECT, TRUE);
tb.GetToolBarCtrl().HideButton(ID_DISCONNECT, FALSE);
also (from MSDN):
Customizing a Toolbar
A toolbar has built-in customization features that you can make available to the user by giving the toolbar the CCS_ADJUSTABLE common control style. The customization features allow the user to drag a button to a new position or to remove a button by dragging it off the toolbar. In addition, the user can double-click the toolbar to display the Customize Toolbar dialog box, which allows the user to add, delete, and rearrange toolbar buttons. To display the dialog box, use the TB_CUSTOMIZE message. An application determines whether the customization features are available to the user and controls the extent to which the user can customize the toolbar.
As part of the customization process, applications often need to save and restore a toolbar's state. For instance, many applications store the toolbar state before the user begins customizing the toolbar in case the user later wants to restore the toolbar to its original state. The toolbar control does not automatically keep a record of its precustomization state. Your application must save the toolbar state in order to restore it. For more information, see Customizing Toolbars and Using Hot-tracking with Toolbars.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Thanks for the reply!
I am using MFC, and the HideButton method works for hiding buttons on the Toolbar in the MainFrame, but does not work when showing the customization dialog. When the customization dialog is shown, hidden buttons ARE shown in the right-hand list (populated buttons), but are shown with grey text (indicating they are hidden/disabled). ALL buttons not already in the toolbar are shown in the left-hand list (available buttons).
I need to be able to prevent buttons in the toolbar resource from showing up in both the available and populated button lists on the customize dialog. (i.e. make it look like the button does not exist at all).
During the building of the customization dialog lists, there are messages sent that query whether a button should be included, but if you indicate that it should not, then the process stops right there, and no more queries are sent for buttons that follow that one in the resource. (i.e. the first time you say "No" to a button, it aborts the queries for any remaining buttons).
I thought there might be a way to either respond differently to the message, respond to a different message that I am unaware of, or get access to the dialog lists and manually remove the unwanted items before the dialog is displayed.
Thanks again,
Sean
|
|
|
|
|
Then i expect you will have to manually add/delete buttons after you create the toolbar from the resource. Once deleted the buttons should not show in either the left or right cutomization lists.
The problem is you are trying to impliment 2-level customization support and the built-in toolbar customization only supports 1-level. You will have to code the wrapping customization level.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
cmk wrote:
you will have to manually add/delete buttons after you create the toolbar from the resource
Ah Ha! Yes, this is what I had been trying to do, but DeleteButton didn't appear to work for me.
I went back to try again, and I now realize my mistake. HideButton takes a command ID to hide, but DeleteButton takes an index (which you have to get by using CommandToIndex). I had been calling DeleteButton with a command ID. Now I can delete the unnecessary buttons at startup, once I've determined the configuration I need.
I knew there had to be an easy answer.
Thanks very much for your help!
Cheers - Sean
|
|
|
|
|
Well, not quite.
DeleteButton (with index) does delete the button from the toolbar, so it no longer shows up in the right-side list of the customize dialog (like it did when the button was hidden), but it DOES still appear in the left-side (available list).
Doh!
Is there another way to delete/remove the button from the CToolBarCtrl after it has been loaded from the resource?
Thanks again,
Sean
|
|
|
|
|
Okay, finally got it.
When populating the customize dialog, there are messages handled by OnGetButtonInfo. In the handler, I can test for the "forbidden" command ID's, and set the button state to TBSTATE_HIDDEN for those buttons. Now the buttons don't even show up in the available list.
Thanks again (and sorry for being such a dutz!)
Cheers - Sean
|
|
|
|
|
Hallo,
In MFC, I create owner draw buttons(CBitmapbutton class)and i want to hold the button pressed and it should do some action. I tried with the following code:
void userdefined::OnLButtonDown(UINT nFlags, CPoint point)
{
if(m_left.PtInRect(point))
{
AfxMessageBox("its working");
}
CDialog::OnLButtonDown(nFlags, point);
}
In the initdialog, I give the button's CRect parameters to the CRect m_left;..
I tried a lot.. & I really need your help guys ...
thanx in advance ..
kingsly
Assariah Kingsly
Masters in IAE (Bremen,Germany)
Basic VC++ programmer.
|
|
|
|
|
Assariah kingsly wrote:
i want to hold the button pressed and it should do some action.
See this[^] or this[^] article.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|