Click here to Skip to main content
16,006,013 members
Home / Discussions / C#
   

C#

 
Questionhow do my program know that both buttons are down Pin
Umair Ahmad khan28-Aug-04 23:09
Umair Ahmad khan28-Aug-04 23:09 
AnswerRe: how do my program know that both buttons are down Pin
mav.northwind28-Aug-04 23:42
mav.northwind28-Aug-04 23:42 
GeneralRe: how do my program know that both buttons are down Pin
Umair Ahmad khan29-Aug-04 0:57
Umair Ahmad khan29-Aug-04 0:57 
GeneralRe: how do my program know that both buttons are down Pin
Vadim Gusev29-Aug-04 8:02
Vadim Gusev29-Aug-04 8:02 
GeneralRe: how do my program know that both buttons are down Pin
leppie29-Aug-04 8:57
leppie29-Aug-04 8:57 
GeneralRe: how do my program know that both buttons are down Pin
Vadim Gusev29-Aug-04 10:09
Vadim Gusev29-Aug-04 10:09 
GeneralRe: how do my program know that both buttons are down Pin
leppie29-Aug-04 10:24
leppie29-Aug-04 10:24 
GeneralRe: how do my program know that both buttons are down Pin
Vadim Gusev29-Aug-04 13:40
Vadim Gusev29-Aug-04 13:40 
You are mistaken. Need AND. This code works correctly.
It is possible to write so:
private bool buttonPressFlag = false;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
	if (buttonPressFlag)
	{
		Color swap = ForeColor;
		ForeColor = BackColor;
		BackColor = swap;
	}
	if ((e.Button & MouseButtons.Left) == MouseButtons.Left ||
             (e.Button & MouseButtons.Right) == MouseButtons.Right)
		buttonPressFlag = true;
}

private void Form1_MouseUp(object sender, MouseEventArgs e)
{
	if ((e.Button & MouseButtons.Left) == MouseButtons.Left ||
	    (e.Button & MouseButtons.Right) == MouseButtons.Right)
		buttonPressFlag = false;
}

PS: Excuse me. At first time I has not understood your answer.
GeneralRe: how do my program know that both buttons are down Pin
leppie29-Aug-04 21:26
leppie29-Aug-04 21:26 
Generalimagelist problem Pin
blankg28-Aug-04 22:10
blankg28-Aug-04 22:10 
Generalchallenging system.directoryservice Pin
vcorn28-Aug-04 18:50
vcorn28-Aug-04 18:50 
GeneralRe: challenging system.directoryservice Pin
vcorn28-Aug-04 20:37
vcorn28-Aug-04 20:37 
GeneralUTF7, UTF8, ASCII ..... I have problems Pin
Rostrox28-Aug-04 12:22
Rostrox28-Aug-04 12:22 
GeneralRe: UTF7, UTF8, ASCII ..... I have problems Pin
Steven Campbell28-Aug-04 12:44
Steven Campbell28-Aug-04 12:44 
GeneralRe: UTF7, UTF8, ASCII ..... I have problems Pin
Rostrox28-Aug-04 13:02
Rostrox28-Aug-04 13:02 
GeneralRe: UTF7, UTF8, ASCII ..... I have problems Pin
mav.northwind28-Aug-04 23:48
mav.northwind28-Aug-04 23:48 
GeneralRe: UTF7, UTF8, ASCII ..... I have problems Pin
eggie514-Sep-04 5:11
eggie514-Sep-04 5:11 
GeneralLoad image, modify and save Pin
Dominik Reichl28-Aug-04 11:20
Dominik Reichl28-Aug-04 11:20 
GeneralRe: Load image, modify and save Pin
Werdna30-Aug-04 6:45
Werdna30-Aug-04 6:45 
QuestionWay to reduce flicker on tab changes w/background image? Pin
jdrudolp28-Aug-04 8:11
jdrudolp28-Aug-04 8:11 
GeneralAssembly.LoadFrom and custom Type Editor issues Pin
viper299528-Aug-04 5:46
viper299528-Aug-04 5:46 
GeneralRe: Assembly.LoadFrom and custom Type Editor issues Pin
Marc Clifton28-Aug-04 16:12
mvaMarc Clifton28-Aug-04 16:12 
GeneralMemory Error Pin
dbetting28-Aug-04 4:32
dbetting28-Aug-04 4:32 
GeneralRe: Memory Error Pin
dbetting28-Aug-04 10:17
dbetting28-Aug-04 10:17 
GeneralTo change an int or float to text Pin
TehGT28-Aug-04 4:09
TehGT28-Aug-04 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.