![]() |
|
#1
|
|||
|
|||
Porting from VB to C++ (MFC) -> control arraysYo yo yo,
I'm new to the fourm so I'm just saying hello and I'm posting a quick question. In VB I can create a control array of object, how can I create something simmilar in MFC? Thanks |
|
#2
|
||||
|
||||
|
Yes, In VB it would be a lot easier. Just copy and paste, but in MFC, I think you should just declare an array of control, create each element of the array and its done
CPP / C++ / C Code:
Haven't tried this before, but it should work, cause its just the same prinsiple of using an array of a class. __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#3
|
||||
|
||||
|
I have a very similar question, that deals with control arrays. Your help would be really appreciated.
The situation is this: I have, lets say, 5-10 button controls on my form, that I have to hide and show. I programmed for a while in VB and I used control array feature there. Now when I started doing C++, I have some little problems with it. Here's the code that works fine, except for one thing. CPP / C++ / C Code:
Everything is fine, except for the last control in the array, which is still visible after the execution of this code. I am really confused about this and have no idea how can this not work. I debugged it and it goes through the last control, still it is visible. Any input is welcome! Thank You. Last edited by LuciWiz : 09-Feb-2005 at 02:44.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#4
|
||||
|
||||
|
hi yermolovd,
your problem is that you defined an array of buttons with 3 elements only: CPP / C++ / C Code:
this is what you should do: CPP / C++ / C Code:
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#5
|
||||
|
||||
|
Oh, LOL. Dumb me.
Thanks alot. My brains are too toast already to notice these things, I better be taking some rest. |
|
#6
|
||||
|
||||
|
Quote:
I say that to myself alot when i made stupid mistakes in vb.... I'm pretty beginner to vb.. and try's to apply c++ syntax to vb... __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#7
|
||||
|
||||
|
The other way around for me.
So is this the only way to manipulate your existing components? The only disadvantage for that is that I have to assign each control to an index of the array. |
|
#8
|
||||
|
||||
Need help againIm tryint to create objects, as you mentioned in the second post
I tried using the code from MSDN CPP / C++ / C Code:
If I compile it, compiler gives me error, that pParentWnd is undeclared. In MSDN example it doesnt say how should I declare it, and what it equals. I also tried the same code with 'this' instead of 'pParentWnd'. It goes through the code, but I dont see any buttons created. Maybe it creates them, but somewhere where I can not see them? Any help on creating components is great. I am going to convert that creation to the creation of array of components, which i know how to do now, only problem now is just creating a single component. Thanks. |
|
#9
|
||||
|
||||
|
Ok, could someone please explain why
CPP / C++ / C Code:
This works But CPP / C++ / C Code:
Doesnt...? If I have to go the first way of coding, do I have to create an array of pointers, and then apply the code?.. I'm a bit confused, I'll try to work this out, altough I wouldn't mind some help, because I have to write a program by Friday. Last edited by LuciWiz : 09-Feb-2005 at 02:46.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#10
|
||||
|
||||
|
Quote:
both method is accepable and should work, but you need a litle change in your code. this should be declared in the class defination as a member variable. CPP / C++ / C Code:
its all about scope, if you declare it in the same function, the object(button) scope is only withing the funtion and end when it exits the function. So put the defination in the class defination. On the other hand, CPP / C++ / C Code:
don't have to care for a scope cause its a pointer and it lives as long as you dont 'delete' it. Now, you should see why.. Quote:
yes, you can also make an array of pointers but becarefull when using pointer, if you created it with new don't forget to delete it when youre finished. both ways are ok, but when using pointers, just be extra careful, cause you may get some unexpected debug error.. anyway, friday?? last friday or this coming friday?? Hope I not too late with my help.... __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
Recent GIDBlog
US Elections and the ?Voter?s Responsibility? by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need help with passing 3 arrays into a function | tommy69 | C Programming Language | 14 | 07-Apr-2004 01:22 |
| FREE 25 MB, No Ads, Control Panel, ASP, ColdFusion, PHP, MySQL, Access Hosting | rkmails | Free Web Hosting | 0 | 08-Sep-2003 06:49 |
| Ultra-fast hosting with free setup and a Real 24/7 Support, $5/Mo, Control Panel Demo | hostorange | Web Hosting Advertisements & Offers | 0 | 23-May-2003 08:32 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The