|
You can use the IShellLink interface to place a shortcut in the startup folder, or you can use the registry, and place an entry to your app in the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run Key.
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
|
I have a tree control and WM_MOUSEMOVE is never sent when the mouse is over the tree control. Is there a way I can get it to recieve the message?
-Raffi
|
|
|
|
|
Derive a class from your CTreeCtrl, and handle the WM_MOUSEMOVE in this class.
~RaGE();
|
|
|
|
|
Hi
I'm using this code to insert items into my CComboBoxEx with icons:
BOOL CConfigDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_Images.Create(IDB_ICONS, 16, 1, RGB (0, 128, 128));
m_ctlCombo.SetImageList(&m_Images);
for(int j=0; j<8; j++)
{
CString string;
string.Format (_T ("Item %d"), j);
COMBOBOXEXITEM cbei;
cbei.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT;
cbei.iItem = j;
cbei.pszText = (LPTSTR) (LPCTSTR)string;
cbei.iImage = j;
cbei.iSelectedImage = j;
m_ctlCombo.InsertItem(&cbei);
}
return TRUE;
}
But for some reason my Combobox remains empty. Does anybody know why?
thanks in advance
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
That code looks correct to me, but there are a couple of other things I can think of:
- Is the m_ctlCombo variable hooked up to the actual control properly? Is there a DDX_Control call for it in the CConfigDlg::DoDataExchange method?
- Is the control on the dialog resource actually a ComboBoxEx, or is it only a standard ComboBox?
As a very minor point, I don't like the (LPTSTR)(LPCTSTR)string cast, because I tend to think it's bad practice to cast away the const . How about:
cbei.pszText=string.GetBuffer(0);
...
m_ctlCombo.InsertItem(&cbei);
string.ReleaseBuffer();
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Mike Upton wrote:
Is the m_ctlCombo variable hooked up to the actual control properly? Is there a DDX_Control call for it in the CConfigDlg::DoDataExchange method?
void CConfigDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO, m_ctlCombo);
...
Mike Upton wrote:
Is the control on the dialog resource actually a ComboBoxEx, or is it only a standard ComboBox?
class CConfigDlg : public CDialog
{
public:
CConfigDlg(CWnd* pParent = NULL);
enum { IDD = IDD_CONFIG };
CComboBoxEx m_ctlCombo;
I don't know what's wrong
modified 12-Sep-18 21:01pm.
|
|
|
|
|
What does InsertItem() return?
suggestions:
1. you don't need invoke GetBuffer(0). you can use just Lock() and UnLock().
2. Clear COMBOBOXEXITEM before using by ZeroMemory().
3. set cchTextMax in COMBOBOXEXITEM
|
|
|
|
|
Gregor S. wrote:
Mike Upton wrote:
Is the control on the dialog resource actually a ComboBoxEx, or is it only a standard ComboBox?
class CConfigDlg : public CDialog
{
public:
CConfigDlg(CWnd* pParent = NULL);
enum { IDD = IDD_CONFIG };
CComboBoxEx m_ctlCombo;
Sorry, that's not what I meant. What I meant was, did you insert the control into the dialog resource (in the dialog resource editor) as a standard combo box or an extended combobox?
I've just created a test dialog based project using the AppWizard, added an extended combo box to the dialog (and used the wizard to add a control variable for it), added a bitmap to use for the images and an image list member in the dialog, then copied and pasted your code into the OnInitDialog method and everything works perfectly.
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Oh, I didn't see the icon for the extended combobox in my dialog resource editor toolbar. I replaced my old comboboxes with the new ones an now everything works fine
Thank you very much for your help!
modified 12-Sep-18 21:01pm.
|
|
|
|
|
hi,
how can i control the position where to insert my text, or is it only possible to append new text?
(i want to insert lines at the beginning of the already inserted text)
thanks
|
|
|
|
|
You could use SetSel(0,0) and then ReplaceSel("your text")
However, this is untested.
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I want to be able to have my application open when I double-click on one of the files that the app creates. I modified my app to take in command line parameters and when I double click on the file, I guess it doesn't send any command line parameters and so the app won't open up. Anyone got any ideas about how to pass in the command line parameters to the application when double-clicking on the file?
|
|
|
|
|
Since the steps are a bit long, so create a temporary project (SDI or MDI).
Normally, you have to call these functions in that order:
EnableShellOpen( );
RegisterShellFileTypes( TRUE );
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (!ProcessShellCommand(cmdInfo))
return FALSE;
in your CYourApp::InitInstance() . You will also have to modify the
resource script for your document type. Let's say you have a MDI App.
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_MYAPPTYPE,
RUNTIME_CLASS(CMyAppDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CMyAppView));
AddDocTemplate(pDocTemplate);
You need to change IDR_MYAPPTYPE resource string to match the extension of your application. The extension is the string just before MyApp.Document .
Like I said, the steps are a bit complex and long but this should get you to start.
Last Article:
Adding VBScript/JScript to C++ App
|
|
|
|
|
hi all the gurus of code
im trying to do some image work using CImage class,i read bout it from msdn. but to my surprise i nvr found it in my default mfc classes..
if out there is some one who had used this class could tell me where could i found more info and how to use kinda things bout it.. ill be highly obliged to him //her
looking forward from all the gurus of code
|
|
|
|
|
It is in atlimage.h. You need to include that
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog<sup<9< sup="">
|
|
|
|
|
I want to have a font dialog in my application and I'd like to use the CFontDialog from MFC but I don't need things like a script selection box and a preview box on mine. I tried just using the flags to turn off those parts that I don't plan to use or have in my dialog, but the dialog looks like crap because the script dropdown is still there, it's just greyed out etc... All I need is the three list boxes for font, font type, and font size. Does anyone know of a way to get rid of that stuff from the CFontDialog class or do I need to create a new dialog that is specific to my needs? If I have to create a new dialog, is there a method I can use to populate the three list boxes with the same data that is populated in the list boxes on the CFontDialog dialog?
|
|
|
|
|
Look at EnumFontFamilies , you can use the LPARAM to pass your combobox or dialog pointer. Last check nFontType to filter only for font type that you need.
Last Article:
Adding VBScript/JScript to C++ App
Jesus Christ is LOVE! Please tell somebody. P. Selormey and I think the same!
|
|
|
|
|
You can use a custom template. You just have to specify the CF_ENABLETEMPLATE flag.
CFontDialog cfd (&MyLogFont, CF_ENABLETEMPLATE |...);
cfd.m_cf.hInstance = AfxGetInstanceHandle();
cfd.m_cf.lpTemplateName = MAKEINTRESOURCE(IDD_MYFONTDIALOG);
When you create your template, just leave off the controls you don't want, and make sure you use the correct IDs for the controls you want to keep.
Control ID
Font Combo Box 1136
Font Style Combo Box 1137
Size Combo Box 1138
OK Button IDOK
Cancel Button IDCANCEL
Help Button 1038
Sample display box 1092
Comment box 1093
This might be an incomplete list, and the numbers might be defined in some header file somewhere, but this should get you going.
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
Hi,
I'm trying to create tool panels like the ones macromedia uses.
I tried it in 2 ways:
1) With CDialogBar derived classes.
This way they allways have the same focus as the parent frame (CMainFrame), but I can't catch
any WM_MOVING or WM_WINDOWPOSCHANGING messages. I need these to make them 'snap' to the borders.
2) With modeless dialogs.
Now I am able to make them snap to the borders, but they do not have the same focus as the main
frame.
Does anybody know how I can catch moving messages in the DialogBar or how to make sure that a modeless dialog has the same focus as its parent ?
would be very happy if someone could help me out cause I'm at the end of my knowledge.
thx
I used to have a life ... now I have a computer
|
|
|
|
|
I have a mainframe function that I want to run from a view. how do I do this? How to get a pointer to the mainframe? What it will do is switch to view2 from view1 when i call it from view1.
Can I do AfxGetMAinWnd->SwitchView from class view1?
Thanks,
ns
|
|
|
|
|
Actually,
I tried
void CFormViewMDIView::OnButton1()
{
CRuntimeClass* pViewClass = RUNTIME_CLASS( CForm2View );
if ( pViewClass == NULL ) return;
CMultiDocTemplate* pTemplate = theApp.m_pView2Template;
if ( pTemplate == NULL ) return;
AfxGetMainWnd->SwitchView( pTemplate, pViewClass );
}
and it doesnt like AfxGetMainWnd->SwitchView( pTemplate, pViewClass );
Error is:
C:\Trainer\FormViewMDISwitch\FormViewMDIView.cpp(157) : error C2227: left of '->SwitchView' must point to class/struct/union
SwitchView is a mainframe function.Helllpp
|
|
|
|
|
Yes... but it's :
AfxGetMainWnd()->SwitchView(...)
You've omitted "()" after AfxGetMainWnd... I think...
Hello World!!!
from Raphaël
|
|
|
|
|
I only have two views in my project. I need to send a user defined message from view2 to view1. How do I get the pointer to view1 which I need in doing pView1->SendMessage (..) from view2 ( If I've understood the senddmessage correctly). Is the view currently on top in the mdiframe the active view? In that case I'm sending a message from my active view (view2) to view1 which isnt active, and understand that I need a pointer to the view the message is going to.
A side question:
Is it possible to send a message from the doc to an inactive view that will make it active? Does it make sense to send a message to an inactive view? Is it legal?
another question. Lets say I have a SwitchView function that lets me switch from one view to another. Now if In my active view i say
SwitchView;
dosomethingelse;
will dosomethingelse get executed? Or is anything after switchview ignored because the view is not active anymore..?
Thanks
ns
|
|
|
|
|
ns wrote:
will dosomethingelse get executed?
Yup! I don't think that code execution in the view will be impacted in any way by the activity state of the associated view window object.
ns wrote:
Is it possible to send a message from the doc to an inactive view that will make it active? Does it make sense to send a message to an inactive view? Is it legal?
Yup again, IMHO. (The sense of course depends on your goal an your application). As you can send messages to inactive windows (I think the "activity" of a window is only important regarding keybord input) via API you can send them to inactive views using MFC as well!
ns wrote:
I only have two views in my project....[snip]
You could get a pointer to the doc object from one view, and then enumerate all the documents views and call SendMessage on them.
Cheers
HTH
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|