|
Hi,
I'm not sure whether this is a fairly straightforward question or a lot to ask, but here goes...
I am creating a small file packing program. For selecting the files to pack, I am using a list box control with three button controls, "Browse", "Select All" and "Delete". Fairly straightforwardly, the combination of these controls lets the user browse for and select files to add to the list box, and to select and delete those items he or she wishes to get rid of etc. Everything is working great... Except that I have just realised that for this particular app the user is going to need to have the option to sort the items in the box by file type as well as by name. So I guess that means that I have to use a list _view_ control instead of a list box control, so that I can use multiple columns with headings and sort by them...
However, I have fallen at the first hurdle, as I am having problems finding concise information about how to set this up (I am relatively new to coding). My main problem is probably that I'm using _NO_ MFC, and all the tutorials/examples I can find seem to use MFC. Also there is a vast amount of info and a _long_ list of message descriptions on MSDN, but I can't seem to find any straight WinAPI examples that show the basics of setting up and populating a multi-column list view.
Could someone please point me towards a _NON_ MFC, standard C WinAPI tutorial/thread with info/any information at all on using list view controls to display a list of items with multiple columns? What I'm really aiming for is a simplified version of the sort of file list you get in WinZip or Windows Explorer (I just need to show file name, file type and path).
Many thanks to anyone who can tell me where to begin,
KB
|
|
|
|
|
Read this
You can also download ListView sample here
|
|
|
|
|
I've just started to read the Visul C++ .NET Bible hoping to learn how to master MFC. I really like book - but I'm having some problems early on.
I'm trying to create this Dialog App as explained in the text. It's about DDX and I need to wire up an edit box with a DDX value variable. So, I do the following (as explained in the text):
1. Click on the edit box in the dialog desinger.
2. Right click.
3. Choose Add Variabel from the context menu.
4. Deselect the "Control Variable" checkbox so I get a DDX value variable instead of an DDX Control variable.
5. Enter my desired type (CString) and name (m_strMessage).
6. Click Finish.
Then in a button handler I write this(again as explained in the text):
<br />
void CHelloDialogDlg::OnBnClickedOk()<br />
{ <br />
UpdateData(TRUE);<br />
AfxMessageBox(m_strMessage);<br />
}<br />
What's suppossed to happen is this: I click an OK button and the dialog apps takes what's in the edit control and show it in a message box.
It doesn't work. Very puzzeling.
So, I downloaded the source code form the books homepage (the authors ditto was down apparently so I went to the publisher's site) and looked through that.
As expected there were discrepancies. Specifically his code had this:
<br />
void CHelloDialogDlg::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CDialog::DoDataExchange(pDX);<br />
DDX_Text(pDX, IDC_EDIT1, m_strMessage);<br />
}<br />
Whereas mine had only this:
<br />
void CHelloDialogDlg::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CDialog::DoDataExchange(pDX);<br />
}<br />
Seeing this I thought I might have done a mistake when wiring up the edit box to a DDX value variable. So I tried to add yet another variable (following the same procedure as above).
Alas, same result. Somehow the edit box doesn't get wired up to my variable. I've now read the same section in the book over and over and over again; I do just as explained.
So I'm thinkign maybe something's wrong with my VS? (I'm using Visual Studio .NET 2002).
Anyway, this is getting rather long. Any ideas? Did I do something idiotic?
(BTW I really do like the book althoug I'm only 20 pages into it. I've read approx. 100 pages in a book on a similar subject: "Progamming Microsoft Visual C++ .NET" from Microsoft Press but I didn't like it so I went out and bought this one instead. Much better....very much indeed ;P)
Help
|
|
|
|
|
I think I've just found the error. Apparently it's an error in the book. And a big one as well. I'm not supposed to deselect the "Control Variable" checkbox, instead I need to change the Category combo box from Control to Value....hmmm....
Am I right?
|
|
|
|
|
First off, thank you for purchasing my book. Second, your problem can be chalked up to the joys of writing a book while working on a beta product As a result when the UI changed in Visual Studio, that particular demo became incorrect. Here's how to solve the problem.
Instead of checking or unchecking the "Control variable" check box, you need to select the appropriate entry in the Category combo box. Long story, short. Microsoft using ambiguous terms to represent two different things. Checking the "Control variable" checkbox is how you tell Visual Studio that you're either creating a simple member variable for a class (non-DDX) or you're creating a DDX variable that will be associated with a control on the dialog.
The Category combo box is where you state whether you're creating a value DDX member variable or a control DDX member variable. In your case, you need to keep the "Control variable" checked and select Value from the Category combo box. You'll then see a default type of CString. Simply type in your variable name and ignore the bit in the book about having to manually add a DDX_Text entry.
Sorry for the confusion.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Don't worry about it. It's straightened out now. Thanks for clearing up the why's and how's
So that's why that error sneaked in there - because of a beta product. Well, that's hardly your fault then.
Anyway I'm still reading, and so far I'm getting my money's worth. It's really good - so there you go.
Well I'll return to the wonders of Documents and Views in MFC now. Take care.
|
|
|
|
|
You're very welcome. Now that I've finished my "Extending MFC Applications with the .NET Framework" book, I'll be putting up a book support site this weekend that will contain things like an errata and discussion board. If you'd like I'll email you once it's live (aiming for Monday).
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
I would very much like that; yes please. I'm also the happy owner of Inside C# 2nd Ed, i.e. such a site could come in handy
Thanks again...
|
|
|
|
|
Greetings,
I am trying to print some text data from a form view, and I overwrote the "OnPrint" to ouput text data from some edit fields on the form. I just get the string member data from the edit boxes, and do a drawstring on the dc.
The printed hard copy output of the text outputs fine, but when I do a preview of the text it appears to be a much smaller font size, and hardly shows up in the preview window.
I assume it has something to do with it be screen coordinates, whereas the printer coordinates are different. But I am not sure.
Thanks in advance for any suggestions.
|
|
|
|
|
Does anyone know how to implement docking toolbars in a dialog app? There are articles about toolbars in dlgs but the ones for docking all use EnableDocking called on CMainFrm which as far as I can see is not available.
|
|
|
|
|
Add a toolbar data member to your dialog class then in oninitdlg
m_Tool.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC );
create your toolbar
then right after that call
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
and that should do it
|
|
|
|
|
Hi!
I have a problem
Well, I have a MS Web Browser activeX in my application, and I want to fill in automatically the username and password in a htaccess authenticatification window (like logs.powerhouseprogramming.com [^]). If you have any idea at all how to do this, please let me know.
Thanks!
PS: you can write directly to dorutzu@personal.ro
|
|
|
|
|
yea..I also wanted to know what if we wanted to fill the form on the webpage automatically (This is bit different that the question asked)
like latest GOOGLe toolbar does...
Thnaks in advance..
|
|
|
|
|
You probably could use appropriate POST request, but it will require some winsock spying. I assume that site intstalls cookie on authorisation.
However, I would probably go with well tested by me techniques of just writing win32 hook, or spawning a separate thread:
that will wait for:
1. ShowWindow or FindWindow (Caption: "Enter Network Password", class #32770(Dialog));
2. GetDlgItem(0x411) -> should exist, it should be static control and GetWindowText should return "logs.powerhouseprogramming.com";
3. GetDlgItem(0x4C2) -> should exist, it should be edit control and here you SetWindowText to "UserName";
3. GetDlgItem(0x4C3) -> should exist, it should be edit control and here you SetWindowText to "Password";
4. After you've done all 3 above: just Send or PostMessage to the dialog: WM_COMMAND, IDOK --> "OK" button has id=1 (IDOK)...
Use SPY to see if I'm right in above sequence.
Don't blame me, not the best solution: but fast to implement...
Regards
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I have an application where the user opens many files at once ( MFC MDI ), and the filenames are stored in the MRU list under the File menu. That is fine with me. I would like to disable all these filenames showing up under "Recent Documents" in Windows XP. Is there a way to open files in Win32 and MFC so that the documents do not show up in this list ?
|
|
|
|
|
Are you not wanting files added to the MRU list itself (a CRecentFileList object maintained by CWinAPP), or are you just not wanting the items from the MRU list showing up in the File menu?
Read Paul DiLascia's August 1999 MSDN article about this very subject.
http://www.microsoft.com/msj/0899/c/c0899.aspx
|
|
|
|
|
Checking the MSDN
void LoadStdProfileSettings( UINT nMaxMRU = AFX_MRU_COUNT );
states
Call this member function from within the InitInstance member function to enable and load the list of most recently used (MRU) files and last preview state. If nMaxMRU is 0, no MRU list will be maintained.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Sorry, maybe I'm not being clear.
When you click on the start button in Windows XP, a small window pops up and one of the selections is "My Recent Documents". I do not want my files to be added to THAT list.
|
|
|
|
|
Hi,
I'm having a problem with a combobox using VC++ 6 and Windows 98.
When I click in the combobox and call his ondropdown event, it seems that the mouse focus stays in this object and if I click (using mouse) in another control of the dialog, my code calls again the ondropdown event of this combobox.
So, I'm not able to click using mouse in another part of the dialog.
Some tests I have made show that this behaviour occurs just on Windows 98 SO.
Could anybody help me out, please?
Thanks in advance,
Felipe
|
|
|
|
|
I has found a article in the Knowledge Base Q326254.
The important point is
... When the ComboBox control is dropped down, the ComboBox captures the mouse to use its input to select the items that are in the ComboBox. ...
It means, only the ComboBox receives mouse messages while they is dropped down.
MatLin
|
|
|
|
|
Hi all,
I wish to create a dialog from within my non-mfc dll. I want to start the dialog as soon as possible! Can I do it in PROCESS_ATTACH...? The docs says only simple initialization is allowed there.
Anyone?
/T
|
|
|
|
|
In DLL_PROCESS_ATTACH, I call a function that creates and displays the window. Don't know if this is the correct way, however it works like a charm.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Can you not have the dialog as a static instance of the dll? Then the dialog will be constructed as soon as the dll is loaded, and its done in the correct order?
|
|
|
|
|
Another way is to define a function Initialise, and when the app loads the dll, call GetProcAddress(yourdllhandle, "Initialise"), which returns a pointer to the function which you can use to start the dialog, whether its modal or not.
|
|
|
|
|
Read the docs on DllMain() , it has lots of warnings about what you aren't supposed to do, such as call APIs outside of kernel32. If your code works, then you're lucky.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--=
NO CARRIER
|
|
|
|