C# :: Setting Global Hot Key On Second Form?

Jun 23, 2014

I created a WinForm app in C# using VS 2013 Express.

I added code to create a Global Hot Key on the main form. This works fine. My hot key is Ctrl-T. I can press the hot key and make the main form show and hide.

Then I created a second form (ChecklistForm) and now I want to press ctrl-T and make that form show and hide. I do not need the main form to do this any more. I just used the main form to test my Global Hot Key code.

So I'm having trouble getting the second form to respond to the hot key. When I put a break on the WndProc(), there is no break.

namespace ChecklistFSX {
public partial class MainForm : Form {
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(String sClassName, String AppName);
private IntPtr thisWindow;
private GlobalHotKeys hotkey;
public MainForm()

[code]....

View 2 Replies


ADVERTISEMENT

C Sharp :: Create Instance Of Form Into Non Form Class To Access Button / Label

Nov 23, 2014

I have a non form class. I want to update label/ check status of check box etc.. in non form class ( here resides functions that contains logic). How can i do that ?

View 4 Replies View Related

C# :: How To Access User Control Form One Of The Child Form

Apr 22, 2014

I hav created mdi parent form that contain one user control. I want to access that user control from one of the child form

View 4 Replies View Related

C# :: Login Then Close Form And Open Main Form

Aug 25, 2014

This is more of a Application Design question, Let's say I have Form1(Login), this is opened from Program.cs, when the user enters details, the Event Handler makes a instance of a class, adds the data and stores the instance within Program.cs class.

So the best thing to do here, is to close the Form1(Login) and open Form2(Main) via Program.cs so that I can send the List<Login> object with my Login instance objects to said form. This form will remain open throughout the applications use as it's like the main GUI for all the programs functions.

When I close this form, I may want to save some information before the application is terminated, so I may as well store the Login instances in Program.cs anyway.

Main stepping stone: Multiple (usually around 3 max) users can login this system if need be, which will mean closing Form2(Main) and then opening Form1(Login) so that once Form1 is closed it can recreate the From2(Main) form and pass the new List<Login> to that form.

What's the best way to do this, at the moment i'm creating the Form2 instance like so:

//....
//Detect the Login form being closed
loginForm.Closed += new EventHandler(OnLoginClosed);
//...
//Open the main form when the login is closed
private void OnLoginClosed(object sender, EventArgs e)

[Code] .....

This seems like it will work and do the job, but is there a better and cleaner way? The List<Login> will be passed to Forms which are created via Form2(Main) as this information will be needed. It's just that ive been told not to use Forms for too much data containment.

View 2 Replies View Related

C# :: Sharing Variables From Login Form To Another Form

Mar 10, 2015

I have a form with 2 text boxes (Email and Password)

The user fills in the text boxes and clicks on the Log in button. The code behind the log in button does the following, First connects to a table (Users) in phpmyadmin. Next runs a SQL query (SELECT * FROM `users` WHERE Email = '" + sEmail + "' AND Password = '" + sPassword + "'") sEmail being the variable created from the text entered in Email text box and the same for password.

Next if the record count == to 1 it opens up the main menu form and if the record count == 0 it fails and the user does not get to the main menu.

All of the above is fine and working however what I want to do is take over a variable from the log in form to the other forms.

The code is below for the sign in button as all my code is behind that (I think this may be where I'm going wrong).

public partial class WelcomeForm : Form{
public static string connStr = "server = localhost; " +
"database = ppw5; " +
"uid = James; " +
"pwd = buster;";

[Code] .....

And the Main menu form where I'd like to take a variable over with me, lets assume the variable is the UserID from the database table that I pull from the dTable I created.

public partial class MenuForm : Form {
//Call the CloseProgram class and create a new method called ClassClose.
CloseProgram ClassClose = new CloseProgram();
WelcomeForm User = new WelcomeForm();
public MenuForm() {
InitializeComponent();

[Code] .....

View 7 Replies View Related

C# :: Calling Method In One Form From Another Form?

Dec 6, 2014

I have a program which when a button is clicked on Form1 it runs a vision system operation on an image in a window on a Form1. There are also other buttons on the Form1 which can change things like threshold levels so the inspection can be run again with different settings. It all works fine but I want to change it to remove the buttons from Form1 so that when the user clicks on a button on Form1 it opens up another form, Form2, and all the buttons which were on Form1 are now on Form2 and the image analysis should run on Form1 when the buttons are used on Form2. I have taken over all the code from Form1 to Form2 and I'm trying to make this happen by creating a new oject on Form1 which calls a method on Form2 which contains the code which was in Form1 and called when the button was clicked on Form1 - not working!! I have a constructor in Form2 but I think I have become monumentally confused.

This was the code which was on Form1 when the inspection button was clicked.

private void cmdInspectOnce_Click(object sender, EventArgs e)
{
iReturn = VisionSystem.InvModeSet(IpeEngCtrlLib.I_MODE.I_EXE_MODE_ONCE);
if (_imgEngines!=null && _imgEngines[0]!=null)
_imgEngines[0].cmdInspectOnce();//InvModeSet(IpeEngCtrlLib.I_MODE.I_EXE_MODE_ONCE);
}

View 1 Replies View Related

C# :: Selection From 1 Form DatagridView On Second Form

Sep 5, 2014

I have 3 Windows Form: frmMain, frmFirstForm, and frmSecondForm.

frmMain is the form that will load when the application is started with 2 tabs to access frmFirstForm and frmSecondForm.

Here's my problem:

After making a selection from a combobox on frmFirstForm, I would like a datagridview header to change based on the selection made. Here is a list of items on one combobox: Item1, Item2, Item3, Item4. When somebody chooses Item one, the header on the datagridview on frmSecondForm should display: JohnItem1, PaulItem1, BradItem1 and so on. Those items are not part of the comboboxes, but they will be shown as header text on the datagridview on the second form either automatically or after clicking OK from frmMain. There's no OK button on frmFirstForm, but on frmMain.

The only code I have right now is the if statement on the form load on frmSecondForm. Here's what I have:

private void HeaderTextLoad() {
if(comboboxonfirstform.text = "Item1") {
datagridview1.Columns[0].HeaderText = "ItemJohn";
datagridview1.Columns[1].HeaderText = "ItemPaul";
... And so on.
}
}

View 1 Replies View Related

C++ :: How To Convert Compact Form Of Matrix Into Matrix Form

Oct 4, 2014

3 3
2 1 3 2 3
1 0 2
1 2 6

First line shows row and column number

First index of the second line tells the number of non-zero entries of the first row and second index tell the column number where the non zero entry is placed

for 1st row of matrix:

non-zero entries=2
column number=1
non-zero entry=3
column number=2
non-zero entry=2

covert this in the given form
0 3 3
2 0 0
0 0 6

View 1 Replies View Related

C++ :: Setting Array To Int With Value

Mar 1, 2013

Lets say i have an array with the values 1, 5, 9, and 3. is there anyway to make this so i can have an int with the value 1593 based on those numbers in the array?

View 8 Replies View Related

C++ :: Setting Limit On Cin?

Feb 22, 2013

I want to set limit on cin for example

int i;
cout<<"Please enter 4 digits id: ";
cin>>i

If user enter more then 4 digits it must give an error

View 5 Replies View Related

C :: Setting Values To Pointers

Apr 5, 2014

This function below takes a pointer as an argument. What I expect to happen is, since expr++ has higher precedence than *expr, that is, the primary expression operators have higher precedence than the unary operators, pointer arithmetic should occur where we increment to the second address pointed to by dbuf, and then we should dereference the value at that address. Given that logiv, when i print dbuf[3] it should print the value pointed to at the 4th address in dbuf. However, the value it returns is 0x0 not 0x3. Why doesn't it dereference the value 0x3?

Code: void dfill(unsigned char *dbuf)
{
dbuf = (unsigned char*)malloc(4);
memset(dbuf, 0, 4);
*dbuf = 0x0;
*dbuf++ = 0x1;
*dbuf++ = 0x2;
*dbuf++ = 0x3;
printf("dbuf val: 0x%x
", dbuf[3]);
}

View 1 Replies View Related

C :: Setting Flags In 32-bit Integer?

Oct 18, 2013

I am trying to create the lparam for the WM_KEYDOWN message. I know this is the C programming forum, but my code is standard enough to apply here. According to Microsoft, the lparam must be formatted like this : lParam The repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown following. Bits Meaning 0-15 The repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent.

However, the repeat count is not cumulative. 16-23 The scan code. The value depends on the OEM. 24 Indicates whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0. 25-28 Reserved; do not use. 29 The context code. The value is always 0 for a WM_KEYDOWN message. 30 The previous key state.

The value is 1 if the key is down before the message is sent, or it is zero if the key is up. 31 The transition state. The value is always 0 for a WM_KEYDOWN message. ( WM_KEYDOWN message (Windows) )^ I'm troubled by setting it into the 32-bit value, and I get confused about what exactly happens when the logical or and the bitshift operators are used. I tried to use them below in my code by looking at Stack Overflow for setting a bit. I also don't know how to test for the endianess of my system, and how to handle it if it's big endian or little endian. Here is my code so far :

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

[Code].....

View 2 Replies View Related

C :: Setting 1D Pointer To Array

Oct 27, 2013

I have the following situation:

Code:
void myFun(float *pfMyPtr) {
float Val[] = {0.234, 0,432, 0.322, 0762, 0.984};
pfMyPtr = Val;
}
int main() {
float *pfPtr;
pfPtr = (float*) calloc (5,sizeof(float));
myFun(pfPtr);
}

I would like pfPtr to contain the values of array Val. What am I missing here?

View 5 Replies View Related

C++ ::  Setting A Function To A Variable?

Oct 29, 2014

I need to set a function to a variable of some kind. Then later in the program it needs to run the function that is set to the variable. The variable doesn't need to change after it is set to a function, it just needs to be able to be set to a function. So maybe I don't need a variable? What do I do? :3 Is this even possible? :o

Example:
if (PosRampYes == 0)
{
SomeVariableOrSomething = FirstFunction();
}
else
{
SomeVariableOrSomething = SecondFunction();
}
//later:
SomeVariableOrSomething; //so if PosRampYes is set to 0 then this line would run FirstFunction()

View 2 Replies View Related

C++ :: Setting Variables For Text

Oct 8, 2013

I am trying to find a quicker way of setting the variables for text. here is my code:

sf::Text set_text_values(sf::Text text, sf::Font font) {
text.setFont(font);
text.setCharacterSize(50);
text.setColor(sf::Color::White);
return text;

[Code] ....

And I have tried it like this

void set_text_values(sf::Text text, sf::Font font) {
text.setFont(font);
text.setCharacterSize(50);
text.setColor(sf::Color::White);

[Code] ....

The code compiles and runs but it won't show the text on the screen like it did when i did it manually like this:

int main() {
Hull.setFont(font);
Hull.setCharacterSize(50);
Hull.setColor(sf::Color::White);
}

What is wrong with it?

View 2 Replies View Related

C++ :: Setting All Elements Of Array To 0

Sep 18, 2013

I'm trying to set all the elements of my array to 0 but nothing seems to be working.

.h
#ifndef ServerGroup_h
#define ServerGroup_h
class ServerGroup {
public:
ServerGroup(const int&);

[Code] .....

I want to set each element of the array in servers to 0 based on what is passed into size by numArray.

View 9 Replies View Related

C++ :: Setting The Value Of A Pointer From Function

Feb 20, 2013

I declared a pointer in main with value 0, so I want to change its value so that it points to other variable from a function, I guess the function creates a copy of my pointer that's why whatever I do within function doesn't change the real direction of the pointer in main. I've been trying something like this:

#include <stdio.h>
void redirectionate(char *str, char *ptrCopy);
int main()
{

[Code]....

View 7 Replies View Related

C/C++ :: Setting Constants As Attribute?

Apr 3, 2015

I would like to know how can i set a constant attribute in the constructor. This attribute is an int value that cannot be changed.

For instance:

class Test {
public:
const int x;
public:
Test(const int val);

[code].....

With this code i get compile error!

View 5 Replies View Related

C++ :: Setting Up Invalid Response

Feb 7, 2013

Basically the whole purpose of this program is to prompt the user to use a calculator. Choices 1-6 are valid, but I want to set it up where selecting any other number outside of 1-6 to be Invalid, and will display an 'Invalid Choice' message, and then go back to the main menu.... The main program does work properly, it's the 'Invalid' setup that is giving me problems

Code:

#include <iostream>
#include <iomanip>
using namespace std;

[Code].....

View 10 Replies View Related

C++ :: Setting Up SFML With Eclipse CDT

Aug 12, 2013

I am having trouble setting up SFML 2.1 to run with the eclipse IDE for c++ development. I use MinGW for my compiler.

When I link my include folder, lib folder and dll's it will not run a simple SFML program.

View 2 Replies View Related

C/C++ :: Setting Resolution On Screen

Mar 29, 2015

Just reading some code and come across a section where its setting the resolution on a screen

so like

image->sizeX=640;
image->sizeY = 480;
size = image->sizeX * image->sizeY *3;
float sizeLog = ceil(log((float)image->sizeX) / log(2.F)));

So yea, my understanding of this code is that firstly there is member access and that a resolution is being set.

And then its like 640 * 480 * 3

and then the log of 640 *480*3 ...being divided by something else and being rounded up by ceil

is this the right way to look at it?

and also what is the log(2.F) - i don't really understand that.

View 3 Replies View Related

C :: Use Pointers Instead Of Global Variables?

Oct 15, 2014

I have made an application and I have basically solved everything. But the only problem is that I am using global variables because it felt like the smoothest, so my program is built on it.

But now I've read around and I understand that you should not use these(?). Do you think pointers is the best think to use instead?I have previously declared my board array and some variables as global and I want them in alot of functions.I have read and understand the procedure for the use of pointers so I can use my int's in the other functions by doing like this? Code: #include <stdio.h>

int justprint();
int main()
{
int Row = 2;
int Column = 2;
int *pRow = &Row;
int *pColumn = &Column;
[code]...

But how do I do it with an array like this one? If I declare it in the main function, and then want to use it in other functions.Or are there better, easier solutions?

Code: char game[3][3]={{0,0}};

View 13 Replies View Related

C++ :: How To Create A Global Object

Jan 18, 2013

if (choice ==1){
Light *myobj = new Light();
}
FlipUpCommand switchUp(*myobj);

Error: `myobj' undeclared (first use this function)

How to solve this problem without changing the Light class.

View 4 Replies View Related

C++ :: Access EXE Global Variables From DLL

Jun 25, 2013

On linux, I can compile DLLs (shared objects) as well as executables that use them. I can even access globals and classes that are defined in the EXE from the DLL, and vice versa, simply with the 'export' keyword. flawlessly.

The Problem: But on Windows (using MinGW), no matter what I do, I'm completely unable to access global variables which defined in the EXE, from the DLL. On Linux, this is no sweat, but what's Windows' problem?

I also need to extend classes in the dll with base class method definitions defined in the exe.

Ive heard that on Windows, you need to use declspec(dllimport) and declspec(dllexport). I can compile with CygWin+MinGW/g++4.5.3 as well as "Pure Windows" with MinGW/g++4.7.2 *without* the declspecs. So what's the decljunk for? Is this really just something for MSVC or other compilers?

Here's some Windows code to show what the problem is. The DLL's global variable is accessible to the EXE just fine, but the EXE's global variable is not accessible to the DLL - compilation complains it is an undefined reference.

main.cpp
#include "myLib.h"
#include <stdio.h>
int exe;

[Code].....

edit: I tried using --enable-runtime-pseudo-reloc --allow-shlib-undefined options when compiling the DLL and G++ complains that --allow-shlib-undefined is an unrecognized option.

View 1 Replies View Related

C++ :: Setup Global Variables

Feb 23, 2015

I am using VS2010 to develop an app which includes several windows forms that I am trying to set up global variables for, and I am getting a few errors like:

LNK2005: "wchar_t *dsn"...already defined in ....obj

I have a header file (externals.h) with:
#ifndef MY_GLOBALS_H
#define MY_GLOBALS_H
extern long dbg;
extern wchar_t dsn[50];
extern wchar_t u[30];
extern wchar_t p[30];
#endif

and 2 different forms, each with different namespaces, but both including the above header (#include "externals.h").One of the form .h files defines the values for these externally declared variables like this: namespace PWValidationTools{

wchar_t dsn[50] =_T("MDOTProjectWise");
wchar_t u[30]=_T("api_admin");
wchar_t p[30]=_T("proce55");
long dbg = 1;

public ref class ValidationSetupForm : public System::Windows::Forms::Form {
}

The other form file only uses these variables, never defines them.I am getting the above LNK2005 error only for the variables declared as wchar_t, not the "long" one. why I'm getting the link errors only for the wchar_t variables.

View 1 Replies View Related

C/C++ :: Passing A Global Pointer?

Feb 29, 2012

Let's say I've got something like this:

struct Box{
//something
};
typedef struct Box* pBox;

[Code]....

function fun recieves the address(which is NULL) and then allocates the memory for the Box; Let's say I cannot return the address of new allocated p and I can't also use that pointer p(from main) without passing it into a function.

Q: How can I make it that I could operate in function "fun" as I operate on orginal pointer p(from main), right now I'm just passing the address to my function but I can't change the 'global' pointer p ;(.

I remember in pascal it's like:
"function(var pointer:[pointer to sth])"
and all is done.

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved