Basically I am creating a game and I need the ai to look for specific buttons. At the moment this is the code I have, and what it does is it makes the ai look for any random button that has't already been clicked.
Code:
private Button look_for_spaces() { Console.WriteLine("Looking for spaces"); Button b = null; foreach (Control c in Controls) { b = c as Button; // performs a cast
[Code] .....
Now what I'm trying to do is make the ai go through 4 searches in steps instead of looking for any button. I want it first to look for buttons 1, 2 and 3, if there's a space in any then it will be clicked but if all of them are already clicked it will look for spaces in buttons 4, 5 and 6 and so on if that makes sense. But i'm not too sure how I would do it.
The opjective was to build an c# deskop windows application for an classic car sales company.
My job was the employees section of the application.
my problem is the following
i have 3 tabs summary (overzicht) details mutation (muteren)
on the details tab i have 2 buttons and a search box both the buttons only do somthing on the summary tab where they also need to take the selected row to the field on the other tabs.
the search box is a text box that neds to find the valve in the summary tab and then als so select the full row and put it in the onther 2 tabs fields.
private void Single_Load(object sender, EventArgs e) { //code here for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { //a lot of working code here b[i, j].Click += new System.EventHandler(ClickButton); } } }
What can I do when one of those buttons is pressed (i have the method ClickButton) to know what i and j has he?
I want to make something like this
ClickButton() { if (x%2==0) v[i, j] = x; //i and j should be form the matrix of buttons }
I am developing a small game using MFC in which the game options like new game, save, open, exit etc. can be selected from the menu as well as from the buttons inside the window. I have no problems with the menu but the buttons do not seem to work at all.
The buttons are created at runtime using CButton class. To associate the buttons with the corresponding functions, I just used the same resource ID for the buttons as the menu options, but that did not work. When I click on the buttons, nothing happens. If I assign different resource IDs to the buttons, how do I handle the message map entries? Do I have to write different message map entries for the menus and the buttons while their function is exactly the same?
I have a txt file of drinks, and I want to meak a list of buttons of it (the txt file is build like this: fanta : 2 ), how can I make buttons of all the drinks ( I get the first one in a button , but not the others).
Dictionary<string, double> drank = new Dictionary<string, double>(); string[] words = new string[8]; Button button; <Button> BtnList = new List<Button>();
how can I create a GUI application that can resize also the control buttons. If the user decide to make the windows bigger or smaller I would like my textbox, buttons, etc.. to follow. Like in Java they use a layout manager, but I can't seem to find the answer for c#. I though to use table layout panel, but it doesn't expand when expanding the windows, unless i miss something
I have multiple bitmap buttons of non-square shape. Because of their odd shape I can overlap them and they will still look good on screen, which is what I want - that certain layout.
The problem is that because underlying button in reality is square (which I am subclassing), the bitmap of one button may overlay with the non-bitmap area of the other button (in the underlying square). This means that 2nd bitmap button will not receive notification because the press is registered with top level window only.
Is there a way that both windows can receive the notification and check if they are in the hot spot, they will respond? I know this is against windows design.
Code: private: System::Void GOBUT_Click(System::Object^ sender, System::EventArgs^ e) { int x; x = sender->Location.X; }
Returns error saying Location is not a member of Object^.
I'm trying to create an array of button (user/runtime created buttons) and get different interpretations of the click event depending of wich button is clicked.
For example, if we create buttons[0] I wish to get the 0 or something relevant into the GOBUT_Click event.
I'm trying to find a way to remove an item that has been dynamically added when I change my drop down list selected user. The way this works is I add an edit and delete button dynamically when I select a user. I need to have the existing one be removed when I change users. Here is the code I'm using to build the two buttons. How do I remove them? Do I wipe out the columns and then add the columns again?
I'm pretty much newbie in creating a successful GUI in C++. Although, i managed to create 4 buttons that should show a certain form. Lets say, Form1 is my main form, therefore - Button 1 will open Form2, and Button 2 will open Form3..... But the conditions is - If there is a form that is already open, clicking again on the Button that should open it, will Close it, but all the forms (form1,2,3,4,5) can be enabled together.
Also, a very important note is that whenever i close a form, in any way of closing it (Not the main form) It will "save" the changes i made (Such as ticking checkboxes and so..) and won't reopen it, it will just use "Visible" i guess ?
Notes :
If i use Form2 ^form2show = gcnew Form2;
and then Form2->Show();
I will be able to simply ATTACK the button and open Billions of form2 ^_^
Although, when i use Form2->ShowDialog();
It won't let me open the form3,4,5.
Which isn't so bad, but when i exit from the form2, it won't save my changes (Such as checkboxes..)
I have a calculator with buttons, and when I click the numbers or operators, it goes to a string array. So;
Press 3 Press + Press 2 Press =
and my array is str[0]='3' str[1]=.... so on...
And also I have a C code which calculates the string you entered with some algorhytms and gives a double value as a result. So the question is;
How can I send my STR array in C# to my C program? I mean I want to use my C program as a source code. and How to return that double value to my C# program?
For now, I don't want to change my C codes into C# codes. I want it to keep as is. Just use it as a source code. Is that possible?
I've created a base DLL for all my future DLL's, a way of getting version numbers and such and that compiles fine, but I can't add it into a class for a new DLL. All the headers do have an appropriate cpp to define the function declarations (and they compile fine).
As long as no base class constructor takes any arguments, the derived class need not have any constructor, if one or more arguments are used then it is mandatory for the derived class to have a constructor and pass the arguments to base class constructors. While applying inheritance, we usually create objects using derived class. Then it makes sense for the derived class to pass arguments to the base class constructor. When both the base and derived class contain constructors ,the base class constructor is execute first.
In case of multiple inheritance, the base classes are constructed ,in the order in which they appear in the declaration of the derived class. Similarly in a multiple inheritance the constructors will be executed in order of inheritance. Since the derived class takes the responsibility to supply initial values to the base class,we supply the initial values that are required by all the classes together where the derived class object is declared.
The constructor of the derived class receives the entire list of values of arguments and pass them on to the base constructors int the order in which they are declared in the derived class
Is it possible to overload a variable in a derived class? Example:
struct Circle { int radius() const { return r; } private: int r; } struct Smiley : Circle { // inherits the function int radius() const, but doesn't return Smiley::r private: int r; }
I'm trying to call a function on a derived class that's in a vector of it's base class. I've made the code really simple for illustration purposes:
class Sprite { virtual void update(); } class Enemy : public Sprite { virtual void update();
[Code] ....
I want to be able to just call update() on the items in the vector and the derived class update() functions be called. Currently, it always calls the Sprite update, which makes sense, but it's not what I want. Is there a way to call the derived update function without knowing the type of the derived class?
The place where I should put the return value is marked with ???. SEntityPhysicalizeParams is a struct from another header from which I dont have access to it's source file.
I tried several things but noone seemed to work out and keep getting me either error "function must return a value" or "initial value of reference to non-const must be an lValue".
Here is SEntityPhysicalize where my function is refering to:
I have a big problem with searching a solution for getting access on getters and setters of the derived classes of an interface.
Interface:
class IfParam { public: IfParam(); };
Now I have a derived class for each needed datatype. E.g.
class Int32Param: public IfParam { public: Int32Param(); Int32Param(IfParam* l_param); int getValue(); void setValue(int l_value); private:
[Code]...
My Problem now ist getting access to the getters/setters over the interface. I wish I could initialize the Params like this:
IfParam* param = new Int32Param(); param.setValue(12);
IfParam* param = new StringParam(); param.setValue("String");
But to have access to the getter/setter I have to declaire the functions in the interface as generic functions. But how? I tried to use temlates, but then i have to declaire IfParam as IfParam<int>. Thats a problem because in my original program I do not know which TypeParam the IfParam interface will be initialized with when I create the pointer.
class Var { public: Var(); ~Var(); private: QMap<QString, QSharedPointer<Data>> _mapVars; }; QDataStream &operator<<(QDataStream &stream, const QSharedPointer<Data> p_data); QDataStream &operator>>(QDataStream &stream, Data &p_data)
I want to serialize _mapVars into a file. However, I have many other classes that are derived from Data, do i need to check for Data type inside the overloaded << functions like below in order to serialize ??? This doesn';t seem to be very correct ...