Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
T

Trucker

@Trucker
About
Posts
23
Topics
9
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • listview items dont appear
    T Trucker

    it is returning a positive value but the items still do not show up. TraileR ParK LifE 4Ever

    C / C++ / MFC c++ help question

  • listview items dont appear
    T Trucker

    Hi David, InsertItem() returns a positive value if successful or -1 otherwise. TraileR ParK LifE 4Ever

    C / C++ / MFC c++ help question

  • listview items dont appear
    T Trucker

    Hello, In my MFC application, I am having a problem with my listview's items. They don't show. It looks like they are there because when they load the scroll bars appear. The following code is OnCreate() where I Initialize the listView: int CTopRightView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; SetWindowLong(GetListCtrl().m_hWnd, GWL_STYLE, WS_VISIBLE|WS_CHILD|LVS_LIST); COLORREF c = PALETTERGB(200, 70, 130); GetListCtrl().SetBkColor(c); //creating image list for listview smallImageList.Create(16,16,false,1,0); //adding icon to image list HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON3)); smallImageList.Add(hIcon); GetListCtrl().SetImageList(&smallImageList, LVSIL_SMALL); return 0; } And this piece of code adds an item to the listview: LV_ITEM lvItem; ::memset(&lvItem, 0, sizeof(LV_ITEM)); lvItem.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_STATE; lvItem.state = 0; lvItem.stateMask = 0; lvItem.pszText = GetNTS(GetDocument()->fileName); lvItem.iItem = GetDocument()->fileCount; lvItem.iImage = 0; GetListCtrl().InsertItem(&lvItem); Anybody might know what I am doing wrong?:doh: TraileR ParK LifE 4Ever

    C / C++ / MFC c++ help question

  • trouble with UpdateAllViews()
    T Trucker

    I am not sure why this is relevent but anyways... to give you an idea I will tell u what my application is. It is Like Windows Explorer. So left pane is the directory tree, but the right pane holds just the files of selected folder in directory tree (dont worry about the third pane I mentioned earlier). So it could be a little, or it could be a lot of files/items... but lets say it shouldn't be too much because this is just an assignment for school I am doing, not some program for Bill Gates:laugh: TraileR ParK LifE 4Ever

    C / C++ / MFC help question

  • trouble with UpdateAllViews()
    T Trucker

    Hi MailToGops, Thanks for the reply. All views are created and initialized. Below is some code you requested of what I am trying to do: in CLeftView: GetDocument()->FileAction(&strFileName,1); in Doc class: void Ca1interfaceDoc::FileAction(CString* fl, int acn) { fileName = *fl; action = acn; SetModifiedFlag(); UpdateAllViews(NULL); fileCount++; } in CTopRightView: int CTopRightView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; //creating listview folderContents.Create(WS_VISIBLE|WS_CHILD|WS_BORDER| LVS_LIST|LVS_SINGLESEL, CRect(10,10,300,180), this, IDC_FOLDERCONTENTS); LV_ITEM lvItem; ::memset(&lvItem, 0, sizeof(LV_ITEM)); lvItem.mask = LVIF_TEXT|LVIF_STATE; lvItem.state = 0; lvItem.stateMask = 0; lvItem.pszText = "an item"; lvItem.iItem = 0; folderContents.InsertItem(&lvItem); return 0; } void CTopRightView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { //folderContents.DeleteAllItems(); if(GetDocument()->action == 1 /*&& !GetDocument()->fileCount*/){ LV_ITEM lvItem; ::memset(&lvItem, 0, sizeof(LV_ITEM)); lvItem.mask = LVIF_TEXT; lvItem.pszText = GetNTS(GetDocument()->fileName); lvItem.iItem = GetDocument()->fileCount; if(folderContents.InsertItem(&lvItem) == -1) folderContents.DeleteAllItems(); GetDocument()->action = 0; } } The reason I believe OnCreate gets called every time UpdateAllViews() runs is this: *In CTopRightView::OnCreate() I create the list control along with a test item and add this test item. *When I run the application I only see 2 items in the CTopRightViews's list control. The test item added in OnCreate() and the last item that was supposed to be added to the list control (many items are supposed to be added to the list control). So it looks like every time UpdateAllViews is executed it recreates the list control with the test item and the most recent item to be added.:^) TraileR ParK LifE 4Ever

    C / C++ / MFC help question

  • trouble with UpdateAllViews()
    T Trucker

    Hi David, Thanks for the reply. So how would I specify that I want the View to add only new items? The article refers to VC++ 6.1 and older. I am using VC++ .NET. I did not find OnInitialUpdate() function in the .NET Framework for CView, which they talk about in the article. TraileR ParK LifE 4Ever

    C / C++ / MFC help question

  • trouble with UpdateAllViews()
    T Trucker

    Hi, I have an SDI Application with 3 views: CLeftView, CTopRightView, CBottomRightView. CTopRightView has a CListCtrl. In the code for CLeftView, if some condition is met, I want to add an item to the list control in CTopRightView. To do this, in CLeftView I set a Doc var to the item i want to add. Next, I call UpdateAllViews() so it can call my Overridden OnUpdate functions in my views. My overriden OnUpdate function in CtopRightView adds the item set in Doc class to the list control. The Problem: UpdateAllViews() seems to call OnCreate() before it calls my OnUpdate function, thus clearing all the contents I had in the list control, and then calls OnUpdate(). Is there any way to prevent it from calling the OnCreate()? I don't want to recreate the list control, just add an item to it.:~ TraileR ParK LifE 4Ever

    C / C++ / MFC help question

  • why does CListCtrl.InsertItem return -1?
    T Trucker

    Wow! Thanks a lot! I did not know about this function.:rolleyes: TraileR ParK LifE 4Ever

    C / C++ / MFC question c++ help

  • why does CListCtrl.InsertItem return -1?
    T Trucker

    Hello, I am having a weird problem with a list view control (CListCtrl) in MFC. I can create it but for some reason I can't add an item to it. When I call the controls InsertItem function, it returns -1, which according to the MFC documentation means that adding the item to the list view was unsuccessful. I know this from running this code: //creating listview folderContents.Create(WS_VISIBLE|WS_CHILD|WS_BORDER| LVS_LIST|LVS_SINGLESEL, CRect(10,10,300,180), this, IDC_FOLDERCONTENTS); LV_ITEM lvItem; lvItem.mask = LVIF_TEXT|LVIF_STATE; lvItem.state = 0; lvItem.stateMask = 0; lvItem.pszText = "an item"; lvItem.iItem = 0; //add the item to the listview. If unsuccessful //then change background color of the list view if(folderContents.InsertItem(&lvItem) == -1) { COLORREF c = PALETTERGB(150, 90, 130); folderContents.SetBkColor(c); } When I run the application, backgound color of the list view (named folderContents in above code) is changed. So why cant InsertItem add an item to the list view? There is no explanation in the documentation. Anybody know?:confused: TraileR ParK LifE 4Ever

    C / C++ / MFC question c++ help

  • MFC - message handling function does not seem to run
    T Trucker

    Hi, I seem to be stuck in this MFC coding world...:wtf: I made a treeview and I coded a message handling function that handles the message =TVN_SELCHANGED (when a tree item is selected). I did this first by going to the properties of my CLeftView class and clicking 'messages' button, then scrolling to =TVN_SELCHANGED and selecting the item from the drop down list to add the function for this message. Then I coded it. But for some weird reason that function does not seem to execute when I run my program and select an item in the tree.:mad: What gives? I am a newbie in MFC, I am more comfortable in .NET, but already dislike to program in MFC - its just so much easier in .NET.:sigh: Anywas, if anybody knows what Im doing wrong, or maybe what im not doing that Im supposed to, if you could point it out to me, I would appreciate it greatly. Thanks. TraileR ParK LifE 4Ever

    C / C++ / MFC csharp c++ data-structures help question

  • getting drive type in .NET
    T Trucker

    Hi, I am trying to get the types of drives (floppy, hard disk, CDROM, etc.) that Directory::GetLogicalDrives() returns. Directory::GetLogicalDrives() returns an array of strings. How do i get this in .NET? TraileR ParK LifE 4Ever

    C / C++ / MFC question csharp data-structures

  • getting first root node of treeview
    T Trucker

    Ofcourse! Here I go again thinking 'inside the box';P. Although I don't see the use of a function like TopNode that returns the first fully visible node... I mean cmon, who would want to get a node like that? Anyways, your answer is exactly what I was looking for. Thanks again:) TraileR ParK LifE 4Ever

    C / C++ / MFC csharp dotnet data-structures question

  • getting first root node of treeview
    T Trucker

    Thanks for the reply David. I simply chose to just get the first root node through the treeview.Nodes.get_Item(0) property, like Jose suggested but your way definitely works as well. Thanks. TraileR ParK LifE 4Ever

    C / C++ / MFC csharp dotnet data-structures question

  • getting first root node of treeview
    T Trucker

    Hi, I am using TreeView.TopNode to get the first root node of my treeview. This does not work for me all the time however. If you read the .NET Framework on this property, I think they state this also by saying: Initially, the TopNode returns the first root tree node, which is located at the top of the TreeView. However, if the user has scrolled the contents, another tree node might be at the top. I don't understand why the TopNode would return a different node after a user scrolled through the treeview.:confused: Does anybody know why? And in this case, how else could I get the first root node? Thanks. TraileR ParK LifE 4Ever

    C / C++ / MFC csharp dotnet data-structures question

  • how to set selected node of treeview through code
    T Trucker

    To Christian - this is a Managed C++ question, (Visual C++ .NET) To Jose - Thanks for da tip. I changed my signature but the Quote button still refuses to work. I suspect its because it doesn't like any brackets in the message contents but I decided to not take those out because it would make the message less organized (...or maybe because im just to laizy to reorganize everything;P). In any case, if its not too big of a trouble, can u please just manually refer to the part of my message you want to reply about . Thanks! TraileR ParK LifE 4Ever

    C / C++ / MFC help csharp dotnet data-structures json

  • how to set selected node of treeview through code
    T Trucker

    Hello, In my Application I made a treeview that displays the system directory structure - like the tree on the left in windows explorer. I also have an Open button that opens a file (OpenFileDialog). So basically my user can browse for a file through the directory tree (the treeview) or through the Open button. My problem is this - If the user chooses to use the Open button to open a file, when she/he does so, I want the treeview to reflect the location of the opened file. That is, to expand appropriately from the root and select the folder that contains the open file. So far I have tried several approaches but none led to a solution:doh:... 1) I looked in the .NET Framework, in TreeView class, for a function that takes a full path and is able to expand to and select the resulting directory. I could not find such a function. 2) I was successfull in parsing the full path I got from the open file dialog window into directories. However I found no functions in the .NET Framework that could help me track from the root to the last directory of the treeview. If anybody knows how to solve this problem or has an approach to solving it, I would appreciate hearing it greatly. TraileR ParK LifE 4Ever

    C / C++ / MFC help csharp dotnet data-structures json

  • getting text of selected item in listview
    T Trucker

    It worked! Thanks a lot! ...And I've been trying all those complicated ways when this short line does it! :omg: Thanks again :) TraileR ParK LifE 4Ever >:{

    C / C++ / MFC question csharp dotnet visual-studio help

  • I want a file DLL write by VC++ used in VisualBasic ?
    T Trucker

    U will need to include/import that reference in your VB file. I believe for VB it will look something like this: Imports Adsoft TraileR ParK LifE 4Ever >:{

    C / C++ / MFC c++ tutorial question

  • Taskbar Button don't have the correct status
    T Trucker

    Is your MinimizeBox property of your form set to False? TraileR ParK LifE 4Ever >:{

    C / C++ / MFC help question

  • getting text of selected item in listview
    T Trucker

    Hi All, I have been trying to do this simple task for half a night and as simple as it sounds, I can't get it to work.:mad: I have a listview and I am trying to get the text of the selected item when user selects one (this is a single select listview). I've tried the following but none work:

    System::Void Form1::lv_files_SelectedIndexChanged(System::Object * sender, System::EventArgs * e){

    // Intellisense tells me that there is no '->Text'
    // after Item(0) even though when reading through
    // the .NET Framework, this sounded logical
    String\* sss = lv\_files->SelectedItems->Item(0)->Text;
    
    //Intellisense tells me this does not work either
    ListViewItem\* selectedFile = dynamic\_cast(e);
    String\* sss = selectedFile->Text;
    
    //...and many other unsuccessful ways which I already forgot
    

    }

    So how do I actually get the text of the selected item? Im tired, and passed the pissed off point so any help would be appreciated immensly:wtf: TraileR ParK LifE 4Ever >:{

    C / C++ / MFC question csharp dotnet visual-studio help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups