|
Have a look at ExtractIconEx.
code snippet:
CString strIconFileName = strFile; //file name
if (!strIconFileName.IsEmpty ())
{
HICON hLargeIcon;
if (ExtractIconEx (strIconFileName, 0, &hLargeIcon, NULL, 1) == 1)
{
Debbie
|
|
|
|
|
Iam doing a MFC project for Asset Management .
The requirement is that when a user selects a file ,the application corresponding to that application should open and display /play the file ...
As an example ,if the file is c:\test.doc ,then MS word should be launched and should display the file ..
ANother exmaple is if the file is c:\media.rm ,then the real player should be opened and should play the file ..
How i do it in MFC ,or WIn 32 ???
|
|
|
|
|
check the ShellExecute() API
|
|
|
|
|
ShellExecute(...)
take a look at this function...
I think it's what you need...
Hope this helps.
|
|
|
|
|
Hi I hope you got a path to the file you want to be opened.
CString path;
Call
ShellExecute(NULL, "open",path, NULL, NULL, SW_SHOW);
Should work
|
|
|
|
|
Try to use the ShellExecute API command. See the MSDN libraray for details.
ShellExecute should do the job.
|
|
|
|
|
hi,
i've made a linked list that contains info that i want to read in another function. Wenn i make a new record and insert it into the linked list my programm crashes the next time it reads the list. it can read everything except for the new record.
i think it has something to do with the insertion of a wrong pointer. here's the code for inserting the new record:
<br />
Leverancier->LeverancierID = GetNewLeverancierID();<br />
NewLeverancier = new CLeverancierStruct;<br />
<br />
NewLeverancier = Leverancier;<br />
<br />
m_LeveranciersLijst.AddTail(NewLeverancier);<br />
the "Leverancier" variable contains the info that has to be inserted.
The next time i try to read the new record the programm just crashes on the point of retreving a CString it's value(for the struct).
[]D [] []D []
|
|
|
|
|
The problem is most likely that
NewLeverancier = Leverancier; does not copy the object pointed to by Leverancier into the object pointed to by NewLeverancier : instead, it just reassigns NewLeverancier to point to the previous object (and creates a memory leak BTW).
What you should do is define a copy constructor for the class Leverancier and NewLeverancier belong to and then create NewLeverancier like this:
NewLeverancier = new CLeverancierStruct(Leverancier);
Also, I strongly recommend you that you use some standard container like std::list instead of your own handcrafted container, it'll save you a lot of headaches.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hi,
I think the problem is the assignment operator. If you have not coded an assignment operator for your CLeverancierStruct, the assignment does a shallow copy which will not copy the CString value(s).
Thus you will copy the pointer to a CString object, which doesnot know that it is used twice, producing a memory access failure or something like that.
Remember structs are classes which default to public for all members.
Have a nice day, and post me if this is the reason.
G. Steudtel
|
|
|
|
|
i think this is the reason my programm crashes, but how can i prevent it?
[]D [] []D []
|
|
|
|
|
How to embed a word document inside a form, what are the steps and what control i have to use??
Thanks inadvance
--Kamesh
|
|
|
|
|
Hi,
You got to make your application to be a container. for this the Document should be derived from a COleDocument instead of a CDocument. Create a project with the container option in the third step of the MFC class wizard. by default you'll get an insert object in the Edit Menu. use that and insert MS Word Document. your application would then host an MS-Word document.
|
|
|
|
|
Hi hope someone can help me. I'm using modelesss dialogs in one of my applications but I'm having a bit of trouble. I can create the dialogue fine and also destroy it except I'm having trouble with how to set the check for the dialogue on the window.
At the moment I have a member pointer to the dialog when it is created, on destroying the dialogue in postncdestroy I set this pointer to null.e.g.
void CCommsDlg::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
if(m_pParent)
{
delete this;
((CBuggycontrolappView*)m_pParent)->m_pDlgComms = NULL;
// ((CBuggycontrolappView*)m_pParent)->OnUpdateWindowCommunicationwindow();
}
CDialog::PostNcDestroy();
}
but I'm not sure how to unset the check on the menu. The call I tried above doesn't work because you need a pointer to a CmdUI object which I'm not sure how to get. The check/window goes on and off fine when I use the menu to start and stop the dialogue but when I use the Close or the exit button I get a page fault. the code for the window command is in the view class and is
void CBuggycontrolappView::OnWindowCommunicationwindow()
{
// TODO: Add your command handler code here
m_nCommsToggleState = m_nCommsToggleState == 0 ? 1 : 0;
if(!m_nCommsToggleState)
{
if(!m_pDlgComms) // check to see if the dialogue exists
{
m_pDlgComms = new CCommsDlg(this);
}
}//else
//{ dlg1->OnExitButton;}
else if(m_nCommsToggleState)
{
if(m_pDlgComms)
{
delete m_pDlgComms;
m_pDlgComms = NULL;
}
}
}
void CBuggycontrolappView::OnUpdateWindowCommunicationwindow(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
//enable the menu item
pCmdUI->Enable(TRUE);
//Set the current toggle state
pCmdUI->SetCheck(!m_nCommsToggleState);
}
How can I check / uncheck the menu when I press either my exit(cancel)button or the close cross?
Also if I delete the this pointer in postncdestroy do I need to include a handler for OnClose with the delete this; statement or not?
Thanks Andy
ps sorry if this is stupid I am quite new to mfc.
|
|
|
|
|
This could work:
void CCommsDlg::PostNcDestroy()
{
((CBuggycontrolappView*)m_pParent)->m_pDlgComms = NULL;
CDialog::PostNcDestroy();
delete this;
}
void CBuggycontrolappView::OnWindowCommunicationwindow()
{
if (!m_pDlgComms)
{
m_pDlgComms=new CCommsDlg(this);
}
else
m_pDlgComms->DestroyWindow();
}
void CBuggycontrolappView::OnUpdateWindowCommunicationwindow(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck((int)m_pDlgComms);
}
rechi
|
|
|
|
|
I have a problem with a CEdit control. The control in my application is used to enter parameters for my application. I am using a derived class CNumericEdit, to be able to enter numbers.
Some of my CEdit controls have a restricted value range. E.g. from 100 to 1000. The input of the user should be applied "on the fly". That means if the user enters a number it should take effect immediately _without_ confirming the change e.g. via a button click.
So I am using the ON_EN_CHANGE message.
But this message works too good for me
E.g. if the user tries to enter 150. I get a change event if the user starts to enter '1'. And that may be wrong because '1' may be out of range, but the user wants to enter 150.
So is there a possibilty to ignore change events as long as the user writes into the edit field. Or is there an event if the user has "finished" his input (some sort of input delay)?
I have tried to search for this problem in the internet and here in the archive, but it is difficult to define some useful search keys for the problem.
Thanks in advance.
|
|
|
|
|
Oh Boy,
I once had that kind of problem too. The only solution we could find worked, let's say most of the time.
I can't provide no source code, just the idea.
The solution was, when we encounter a change notification, we started a trigger, which was set to 750 milliseconds. Every change notification renewed the trigger. So the user had the possibilty to enter its text in a fairly slow way. When the time ran out, the trigger fired and the new content was processed.
As far as I can remember it took us (2 persons) two days to get it working as we wanted it to be. Well without coffee breaks and discussions one day.
There is a class CThreadTimer either here at CodeProject or at CodeGure that will help you in the effort.
Regards
G. Steudtel
|
|
|
|
|
It depends on how you distinguish the end of an input?
If you want it immediately, then it has to be after each character input, by definition.
Sure, you could put some sort of timing mechanism in, but this could be unpredictable, for instance taking a sip of coffee whilst entering a number...It would irritate me to have that in a form.
For my forms I only check when the edit control loses focus, or, say, when an Apply/OK is checked etc.
Debbie
|
|
|
|
|
Hello,
I have a long text to print in a MessageBox so I want it on several lines.
I tried something like:
MessageBox(NULL,"Test\n\rTest","",MB_OK);
but it doesn't work!! I want also the string to be loaded from a file so the 'escape sequences' will be in the string!
Thanks
|
|
|
|
|
It works wonderfully for me (also, you can omit the \r part). Test sample follows:
#include <windows.h>
int main()
{
MessageBox(NULL,"Test\nTest","",MB_OK);
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
i tried MessageBox(NULL,"Test\n\rTest","",MB_OK); on my system(win2K) and it works fine???
|
|
|
|
|
hello,
try
MessageBox(NULL,"Test\r\nTest","",MB_OK);
i have try
MessageBox(NULL,"Test\n\rTest","",MB_OK);
on my system(XP) and it works fine ...
|
|
|
|
|
Thanks everybody !
Sorry, in fact I did not try the MessageBox(NULL,"Test\n\rTest","",MB_OK);
but loaded the string from a file !! So the \n is no more interpreted as an escape sequence but as normal text !!
So I think it will not be possible to have such an escape sequence in a text file! Or do you have any suggestion ??
|
|
|
|
|
This depends on the way you are "loading" your text. With a standard fopen(filename,"r") will throw the problem you mentioned, whereas fopen(filename,"rt") won't.
Check the fopen for this in the MSDN.
~RaGE();
|
|
|
|
|
Yes, thanks !
I'll take a look at that !!
|
|
|
|
|
I want to add some text in my progress bar on it's initilization. How to do so.
Reply me soon
|
|
|
|