|
Update registry using RegSetValueEx and broad cast message as given below.
::SendMessage( HWND_BROADCAST,WM_SETTINGCHANGE, 0, (LPARAM) "Environment");
|
|
|
|
|
CListCtrl was used to display file list with icon.
via user click a button 'AddFile' to do this.
via display a CFileDialog for user choose file.
and use SHGetFileInfo to get file attributes, contains icon.
Most of the time, it works correct. but sometimes, icon was missed
while we add file to CListCtrl. after lost icon in CListCtrl.
The CFileDialog shown files just text, but lost icon too.
Anyone meet it before?
|
|
|
|
|
How do you add icons to listctrl?
|
|
|
|
|
hImglist = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), NULL, &rInfo, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON);// SHGFI_SYSICONINDEX);
m_imgList.m_hImageList = hImglist;
...
rItem.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
m_lstSubmitFileList.InsertItem( &rItem );
...
|
|
|
|
|
This isn't going to work well.
You're getting an index to an icon in the system imagelist. Every time you get a new icon the
previous index becomes invalid.
From the docs for SHGetFileInfo()/SHGFI_SYSICONINDEX:
"Only those images whose indices are successfully copied to iIcon are valid. Attempting to access
other images in the system image list will result in undefined behavior."
You need to copy the icon to your own image list which the listview control uses.
Something like this maybe:
HICON hIcon = 0;
SHFILEINFO shfi;
memset(&shfi, 0, sizeof(shfi));
if (SHGetFileInfo(pszPathname,
FILE_ATTRIBUTE_NORMAL,
&shfi,
sizeof(shfi),
SHGFI_ICON | SHGFI_SMALLICON))
{
hIcon = shfi.hIcon;
}
if (hIcon == 0)
{
LPTSTR pszExtension = PathFindExtension(pszPathname);
CString DummyFileName;
DummyFileName = _T("dummyfile");
if (pszExtension[0] == _T('.'))
DummyFileName += pszExtension;
else
DummyFileName += _T(".");
SHFILEINFO shfi;
memset(&shfi, 0, sizeof(shfi));
if (SHGetFileInfo(DummyFileName,
FILE_ATTRIBUTE_NORMAL,
&shfi,
sizeof(shfi),
SHGFI_ICON | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES))
{
hIcon = shfi.hIcon;
}
}
if (hIcon)
{
rItem.iImage = m_imgList.Add(hIcon);
rItem.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
m_lstSubmitFileList.InsertItem( &rItem );
DestroyIcon(hIcon);
}
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|
|
Thanks for your reply.
That seems my colleague fixed this bug ~~
|
|
|
|
|
Hi,
I am trying to run my code in a different system, which is working on my system. But it gives me this error. I checked the path for afxhelp.hm...its correct and is fine...
Can anybody help me with this error please....
Here is the entire copied error message.............
*****************************************************************
Copying contents file...
1 file(s) copied.
Making help include file...
Making help file...
hlp\OperationTool.hpj(1) : error:
Microsoft (R) Help Compiler
HCRTF 4.03.0002
Copyright (c) Microsoft Corp 1990 - 1995. All rights reserved.
operationtool.hpj
HC3037: Warning: D:\Sridhar\Official\NGN\NGN_3\kcj\ngn\OperationTool\hlp\OperationTool.hm :
The map value for "HIDD_SYSTEMCONFIGURATION" is the same as the map value for "HIDR_CSMENU".
HC3025: Warning: topic #3 of D:\Sridhar\Official\NGN\NGN_3\kcj\ngn\OperationTool\hlp\.\afxcore.rtf :
Jump to undefined Topic ID: "HID_OLE_INSERT_NEW".
HC1010: Note:
The following mapped Topic IDs were not used in any topic:
AFX_HIDP_UNREG_DONE
HID_CONNECTION_CONNECT
HID_TOOLS_EMT_LOGSAVE_ON
HID_SYSTEM_USER_STATUS
HID_TOOLS_EMT_LOGSAVE_OFF
...// so on..i have removed them here
...
...
HID_CLOSE
...
...
OperationTool.exe - 1 error(s), 15 warning(s)
Please respond soon.
Thanks,
Sridhar
|
|
|
|
|
Hi
Does anyone know APIs used for monitoring CD and DVD writing. Whenever i write files to CD or DVD i should get some notification
|
|
|
|
|
I'm not sure, but you might look into the IDiscMasterProgressEvents interface.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
can we use document view in dialog based application. how to do this?
|
|
|
|
|
just create a doc view app and derive the view from a CFormView class and viola, you got a doc/view dialog based app... you will however have to confine the size of the dialog or do you own resizing of controls and what nots!
Why do you want a doc view anyways? I mean there are other ways to separate data and drawing code handling, etc
Yours Truly, The One and Only!
Software Developer
Toronto, Ontario
Canada
|
|
|
|
|
actually i have to show windows explorer style window while clicking a button in mfc dialog application. i dont know how to create a windows explorer style mfc program in dialog. pls help me
|
|
|
|
|
why don't you just create a browser style mfc app using the wizard, and inside the OnInitialUpdate create an instance of your dialog box which can be created as a modeless dialog box so you can pass data and message between your doc/view app and the dialog as focus is moved between the two windows.
make sure to make only your dialog box visible and your dov/view app invisible initially.
when the user clicks on the boutton in your dialog box, like magic you make your doc/view browser style window visible and set focus to the view... if you want to hide the dialog box you can, otherwise leave it open based on your requirements.
that's the quick and dirty way to do what you want
GL
Yours Truly, The One and Only!
|
|
|
|
|
I am not sure of how to do this, since normally all window creation is done via InitInstance. But since I have a dialog based app as the "main window" so to speak, I am not sure how to proceed. Do I need to create a new CWinApp derived class, or what ?I have a dialog, that contains a button. When the user clicks this button, I need to create a new frame window, with a splitter pane splitting the main window into two. The dialog invoking this new window should know if the window is closed.
|
|
|
|
|
It going to take some work, but for a splitter window you're going to have to create an instance of the CSplitterWnd, you can pass a window pointer from your dialog box to the splitter window after you create it from the dialog box and use that as a way to communicate events or pass data, or create custom window message and use that between the window to send messages... there are so many ways to do this, find the easiest one that works for you.
In your dialog box add a method that will create the new window and initialize it. Save it to a member pointer variable of type CWnd* use type casting were required to get the actual splitter window, or just declare a pointer to the final window you will be working with.
Check for this pointer to be null before creating the window, then you will need to use CWnd::GetSafeHwnd API to make sure there is actually a window attached to the window pointer!
You don't want to keep creating a window if one already exist, if one exist you simply want to set the focus to it when the User clicks on the dialog button again.
Make sure the destroy the window and free the pointer when you're done with it....while t he app is running you can simple show and hide the window to save you from creating and deleting a window and losing data then needs to be persistent.
You can start off by looking in the MFC section of this site on splitter windows, also you should create a simple mfc test app with a splitter window and understand how the wizard is generating the view and do the same thing or simply grab the class after tweaking it in the test app and plop it into your dialog app project and create an instance of it yourself.
IF you know how to create a modeless dialog box then you have all the know how of creating a simple window my friend, same concept.
That's all the help i can give you, I am not going to provide any code, you will just have to do you due diligence with the particulars!
Yours Truly, The One and Only!
|
|
|
|
|
FYI: There is a splitter tutorial in the MFC section for beginners that you will find helpful! I would provide you the link but I want to teach you how to be resourceful for yourself and get to know how to use this wonderful site
Yours Truly, The One and Only!
|
|
|
|
|
i got u. but how to create a window on clicking a button. i worked in dialog application only. i dont know about windows and documents. pls guide me.
|
|
|
|
|
did you read the article i told you about? did you build a test app like I told you to and look at the generated source!!!
if not do this first
here is an idea,
class MyWindow : public CFrameWnd
{
CWnd* m_pParent;
public:
MyWindow( CWnd* pParent ) : m_pParent( pParent )
{
Create( 0, _T("Hello Window!!!") );
}
};
void CPopupDlg::OnBnClickedButton1()
{
if( m_pMyWindow == 0 ) {
m_pMyWindow = new MyWindow( this );
}
if( m_pMyWindow->GetSafeHwnd() != 0 )
{
m_pMyWindow->ShowWindow( SW_SHOW );
m_pMyWindow->UpdateWindow();
}
}
GL
Yours Truly, The One and Only!
|
|
|
|
|
yes i got the window thank you very much. i will try for the explorer style. is there any link for this.
|
|
|
|
|
i am glad you got something working
unfortunately i don't know of any resource you can look at for your explorer style window, you could try a search for it in this site or google it, or like i said create a test mfc app with the app wizard, pick mfc app and then in the wizard window under the "application type" select "window explorer" for project style and then just look at the view class and how it gets created...don't be scared to dig in, roll in the mud and get dirty like a pig!!!
but here is the link to the splitter window section for you to browse around and find what you're looking for http://www.codeproject.com/splitter/
Yours Truly, The One and Only!
|
|
|
|
|
The Control has been testified by "ActiveX Test Container" which runs very well,then I use Microsoft ActiveX Control Pad to plug in this control.
IE code like this:
<title>USBClientActiveXEx
<object id="yyy" width="320" height="240
" codebase="http://xxx/yyy.cab"
="" classid="CLSID:622FA9EC-C889-4138-A2D2-A6CCB092C914">
<param name="_Version" value="65536" />
<param name="_ExtentX" value="13229" />
<param name="_ExtentY" value="13229" />
<param name="_StockProps" value="0" />
//inf like this
[Add.Code]
yyy.ocx=yyy.ocx
yyy.inf=yyy.inf
[yyy.ocx]
file=thiscab
clsid={622FA9EC-C889-4138-A2D2-A6CCB092C914}
RegisterServer=yes
FileVersion=1,0,0,1
[yyy.inf]
file=thiscab
of course,the cab file includes yyy.ocx and yyy.inf files.But when I place the page in Apachy,remote user can't register the control,what's the matter?
Later buggers harm more.
|
|
|
|
|
Your codes look OK. I think you need check the following things:
(1) File Dependencies
- MFC is shared link or static link
- Any new versions of libraries required
- Require thirty-party libraries
(2) Make sure the class ID "622FA9EC-C889-4138-A2D2-A6CCB092C914" is correct UUID for your control.
(3) Your OCX module is signed? marked as scripting safe?
(4) Web browser setting of the remote user is adjusted to load OCX?
From my experiences, most of time such case is due to (1).
|
|
|
|
|
(1)
-MFC is static link
-No
-No
(2)Yes,it is.
(3)No signed but marked as scripting safe.
(4)allow all active control access.
Later buggers harm more.
|
|
|
|
|
I have several places in my application where I am trying to change multiple GUI objects in the same function. Not all of the changes are actually taking. For instance in the below snip, the 1st SetWindowText() does not always get written, even when the MyDialer.Hangup takes a while (which it often does, it hangs up a RAS connection). The CheckDlgButton seems never to get called because this checkmark persists (it worked at one point until I moved the ::KillTimer() to before the Hangup).
There are other places in my code where I SetWindowText() before calling a lengthy function and then set it again after that function but before calling the next lengthy function and SOMETIMES the second update works and sometimes it doesn't.
I have the feeling that this is one of those things that experienced programmers just know about and how to work around and that's why it's hard to find a doc or write up on it. I also have a feeling it has to do with my stubborn lack of use of the "UpdateData( FALSE );" method. If someone tells me that using that darn thing exclusively will definitely make these objects update every time, I'll change my code ALL around. I'll still wonder very much why these other direct functions don't force the update properly, but I'll change.
note: none of my function calls are multi-threaded so if passing of control of the only thread to another function is affecting this, I thought I'd let you all know that up front. I also am still running VC 6.0 and the PSDK that was last released that supported 6.0 (for the stupid little apps that my company asks me to write they won't spring for a newer V Studio).
m_objInfoWindowLineOne is a CEdit object for one of my text boxes.
IDC_CHECK_TIMEOUT_OVERRIDE is one of my checkboxes.
void CTstDlg::OnButtonHangUp() <br />
{<br />
m_objInfoWindowLineOne.Clear();<br />
m_objInfoWindowLineOne.SetWindowText("Disconnecting");<br />
<br />
::KillTimer(GetSafeHwnd(), IDT_DIALTIMER);<br />
MyDialer.Hangup();<br />
CheckDlgButton(IDC_CHECK_TIMEOUT_OVERRIDE, BST_UNCHECKED);<br />
<br />
m_objInfoWindowLineOne.Clear();<br />
m_objInfoWindowLineOne.SetWindowText("Idle");<br />
<br />
m_strIPAddress.Empty();<br />
UpdateData( FALSE );<br />
<br />
MySQLConnection.WriteDialupLogDisconnect();<br />
}
Thank you unendingly for any light you can shed,
Chuck
|
|
|
|
|
If there's a member variable tied to m_objInfoWindowLineOne (and/or the
IDC_CHECK_TIMEOUT_OVERRIDE button) through DDE then your UpdateData() call is going to write the
contents of that variable to the m_objInfoWindowLineOne control, AFTER you've set the text
directly.
I'm thinking a quick fix for the method you've shown would be to add an UpdateData(TRUE);
before the m_strIPAddress.Empty(); call. It would probably fix it but it's not necessarily
correct or efficient
Maybe for consistency, you could either use DDE or directly set/retrieve info from controls but
not both. If you choose to use both, you need to pay close attention to when controls and
associated member variables are being modified.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the number 3
|
|
|
|