|
Normally when you are developing a windows based application, there are certain set of rules that can be followed for and effective presentation:
1) Always go for a parent-child window forms concept i.e. MDI windows, this will help you to connect the complete flow from single source.
2) Always try to minimize the number of window forms needed for one use, i.e., use only one form for one module for eg. if you are working on the User admin module of the app, wherein u can add and modify users, it is a better idea to put the data in grid and allow for modification/deletion/and addition in the grid itself, it will optimally use the available form space and will leave enuf room for future changes
3) Group related controls together using a group box for e.g. buttons together, and other fields togther.
4) Use same font and color settings thruout the app
5) Hide unnecessary details from the user.
|
|
|
|
|
thanks man
but u didn't tell me how to acess data of recepts and factures ! where the number is a auto increment number
|
|
|
|
|
Hi,
I've encountered a problem where windows preempts for 16ms on a very simple code i'm running.
In order to check it out I've written a simple code :
while (1)
{
int t = timeGetTime();
Sleep(1);
printf ("%d,",timeGetTime()-t);
}
the result i got where interesting - on some machines i got 1-2ms and on others 16ms.
all machines run XP with no processes running in the background.
I've tried running the same process in real-time and in normal mode - the results where the same.
|
|
|
|
|
The code you have written would try to consume 100% of your CPU. When the windows system needs some CPU time it will pause your program and use the CPU. You can set your program to be a higher priority, but I wouldn't suggest that. I guess what I am wondering is what are you trying to accomplish?
Ben
|
|
|
|
|
The parameter specified is not the actual time slept, but is the MINIMUM time that the thread should sleep. It's possible that the thread will sleep longer than the time speicified. Also, this is the minimum time that the thread will return to the ReadyToRUn state. It doesn't mean that the thread WILL run at the end of that time.
Also, if the interval speicified is lower than the resolution of the system clock, the minimum time a thread will sleep IS the resolution of the system clock.
I suggest checking out the docs on the Sleep[^] function.
BTW, the "no processes running in the background" thing doesn't mean anything. Windows has can have over 150 threads running at the same time before you even see a Desktop. These are grouped into many different processes that are needed just to run Windows. So, this statement is actually false and quite impossible to achieve.
|
|
|
|
|
Thanks,
nevertheless, i see consistent behavior - on some machines i see 1-2ms and on others 16ms.
the reason i did that experiment is that i have another simple code, without the sleep
that preempts on some machines to 16ms and on others 1-2ms.
this behavior is consistent.
|
|
|
|
|
So? Link the documentation said, it's system dependant. You have zero control over this. The Sleep duration specified is only specifies a requirement for the MINIMUM time that the thread must sleep, subject to many factors. There is nothing you can do to make the thread sleep for EXACTLY 1 to 2 ms.
|
|
|
|
|
Hi
I have a composite (complex) CustomControl in VB.NET.
In the *.Designer.vb file a control is set to a Settings value:
Me.nudtags.Value = Global.Project1.My.MySettings.Default.pastags
I suspect this fires the ValueChanged event (even though the Designer.vb file calls Me.SuspendLayout?)
Private Sub nudtags_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles nudtags.ValueChanged<br />
<br />
DoMethod(nudtags.Value)<br />
End Sub
The "DoMethod" can not run in design-time, but it fires and runs as soon as I add the control to a form (in the same project).
There must be a way to prevent this event from firing in design time and/or after the CustomControl is loaded in runtime?
PS: I tried Me.DesignMode but with no luck.
|
|
|
|
|
There is no way to stop an event from firing. you just have to get creative in the method you handle it at different times.
The ValueChanged event fires because, well, the value changed. The Value has nothing to do with SuspendLayout.
Normally, the value would be used as design time, as well as runtime, to update the visuals of the control in the designer.
If you wanted to not run the DoMethod, I'd do something like this:
Private Sub nudtags_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles nudtags.ValueChanged
If Not DesignMode Then
DoMethod(nudtags.Value)
End If
End Sub
I've heard of DesignMode not being reliable, though I've never had aproblem with it. You might want to read this[^] for some clarifications.
|
|
|
|
|
I tried exactly what you had there before posting the question. That DesignMode for some reason returns False .
Thanks for the reply. I think that article will be a help...
For now I have worked around it with my own designmode boolean I set to false during runtime
|
|
|
|
|
Hallo
Does anybody know of any method to make a listbox scroll without the user having to do anything. e.g As the form loads the listbox scrolls from the top item to the last item(not by making the mouse click on the scroll button though). Any help would be greatly appreciated.
Thanks
There are 10 types of people in the world, those who understand binary and those who dont.
|
|
|
|
|
hi,
you can use the select item property of the listbox to select the last item whenever a new item is added or after all the data have been added.
hope this helps
regards
|
|
|
|
|
Will try that
thanks
There are 10 types of people in the world, those who understand binary and those who dont.
|
|
|
|
|
Hello,
I'm looking for a simple sample (or a utility class) on how to build a workerthread for a windows forms application in .Net 1.1. But a search on the articles didn't help really.
Following I'd like to do:
-> Start the App and display a Form
-> Upon "start" button click start the thread (it is doing a couple of database and file operations, each of which must be completed entirely, before processing the next one)
-> The thread should be able to update a progress bar on the form and a couple of labels
-> When the user hits the "pause" button, the thread must complete the single operation it is currently working on and then wait until the user stops the whole thing completely or hits the "continue" button
Can anyone please point me into the right direction? Thanks in advance!
/matthias
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
|
|
|
|
|
Here is an application that I made for an interview that calculates prime numbers.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;
using System.Threading;
using System.IO;
namespace Primes
{
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button cmdDoit;
private System.Windows.Forms.ListBox lbPrimes;
private System.Windows.Forms.ProgressBar pbPrimes;
private System.Windows.Forms.Label lblValue;
Thread t;
public MainForm()
{
InitializeComponent();
}
[STAThread]
public static void Main(string[] args)
{
Application.Run(new MainForm());
}
#region Windows Forms Designer generated code
private void InitializeComponent() {
this.lblValue = new System.Windows.Forms.Label();
this.pbPrimes = new System.Windows.Forms.ProgressBar();
this.lbPrimes = new System.Windows.Forms.ListBox();
this.cmdDoit = new System.Windows.Forms.Button();
this.SuspendLayout();
this.lblValue.Location = new System.Drawing.Point(8, 64);
this.lblValue.Name = "lblValue";
this.lblValue.TabIndex = 3;
this.pbPrimes.Location = new System.Drawing.Point(8, 40);
this.pbPrimes.Name = "pbPrimes";
this.pbPrimes.TabIndex = 2;
this.lbPrimes.Location = new System.Drawing.Point(8, 96);
this.lbPrimes.Name = "lbPrimes";
this.lbPrimes.Size = new System.Drawing.Size(136, 290);
this.lbPrimes.TabIndex = 0;
this.cmdDoit.Location = new System.Drawing.Point(8, 8);
this.cmdDoit.Name = "cmdDoit";
this.cmdDoit.TabIndex = 1;
this.cmdDoit.Text = "Calculate";
this.cmdDoit.Click += new System.EventHandler(this.CmdDoitClick);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(152, 398);
this.Controls.Add(this.lblValue);
this.Controls.Add(this.pbPrimes);
this.Controls.Add(this.cmdDoit);
this.Controls.Add(this.lbPrimes);
this.Name = "MainForm";
this.Text = "Primes";
this.Closing += new System.ComponentModel.CancelEventHandler(this.MainFormClosing);
this.Load += new System.EventHandler(this.MainFormLoad);
this.ResumeLayout(false);
}
#endregion
void MainFormLoad(object sender, System.EventArgs e)
{
}
void CmdDoitClick(object sender, System.EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
t = new Thread(new ThreadStart(Calc));
t.Start();
}
void Calc() {
int count = 0;
int max = 1000000;
this.pbPrimes.Maximum = max;
this.pbPrimes.Value = 0;
ArrayList al = new ArrayList();
for (int x = 1; x <= max; x++) {
bool prime = true;
for (int y = 2; y < (x/2)+1; y++) {
if ((x % y) == 0) {
prime = false;
}
}
if (prime) {
al.Add(x);
count++;
}
pbPrimes.Value++;
lblValue.Text = pbPrimes.Value.ToString();
}
lbPrimes.DataSource = al;
FileStream fs = new FileStream("Primes.txt",FileMode.Create);
BufferedStream bs = new BufferedStream(fs);
StreamWriter sw = new StreamWriter(bs);
foreach (int num in al) {
sw.WriteLine(num.ToString());
}
sw.Close();
bs.Close();
fs.Close();
MessageBox.Show(count.ToString() + " Primes were found and written to Primes.txt");
}
void MainFormClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
try {
t.Abort();
} catch (Exception ex) {
MessageBox.Show(ex.ToString() + " Thread could not be stopped");
}
}
}
}
There are 10 types of people in the world, those who understand binary and those who dont.
|
|
|
|
|
I’m looking for a book or website. I have an application this views several different graphic controls in windows within my MDI Form. I would like to create a nice application to for all these images. Several can be open at once. The mouse context and control is same for each, but the control functions can be different.
PS: I’m new to using forms. My past GUIs where written in MFC.
Thanks
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
Hi,
I've my windows form application with Form1.h where i've implemented the graphic interface.
Then i've Myclass.h where i declare a class
#include "form1.h"
....
class Myclass{
public:
Myclass();
~MyClass();
void func();
void func2();
private:
...
}
and the myclass.cpp file where i implement the class.
Two problems:
1-Where must i have to put "Form1^ fr=gcnew Form1" declaration so that any method of myclass can see fr variable?
2-I want to put a condition in func() body that when button1(in the graphic interface of Form1.h) is clicked i do something. How can i write this condition?
Thank in advance for answers, regards.
|
|
|
|
|
Have you figured this out or still working on it?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
1- For the first problem i don't find a solution so i change my code.
2- For the second problem i declare a flag variable that change its value then the button is clicked.
Bye.
|
|
|
|
|
Sounds like you got it taken care of. I was just running through some of the unanswered questions and just seeing if they were still an issue with the poster and if so, I could maybe help out.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I am developing an application which needs to be deployed using click once. We have 4 physical sites connected by a WAN link. I can deploy to a file server in each of these sites for local users to connect and update the app. However we have several roaming users which we do not want to update from site A when they are currently at site B etc. Does anybody know a way I can programatically change the update location for this app for each time it starts up.
|
|
|
|
|
Hi, i've a visualc++ project( window form application).
I've created a class in a cpp file ( and its .h file)with this simple structure:
class Myclass{
public:
Myclass();
~Myclass();
func1();
func2(int n);
private:
int n;
}; and i've implemented the functions.
Then i've my graphic interface composed by some form application.
This is one...Camlive.h
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace WinCam {
public ref class Camlive : public System::Windows::Forms::Form
{
public:
Camlive(void)
{
InitializeComponent();
}
protected:
~Camlive()
{
if (components)
{
delete components;
}
}
private:
///
/// Required designer variable.
///
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
void InitializeComponent(void)
{
this->components = gcnew System::ComponentModel::Container();
this->Size = System::Drawing::Size(300,300);
this->Text = L"Camlive";
this->Padding = System::Windows::Forms::Padding(0);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
}
#pragma endregion
};
}
I want to use it and its components(like a button control or a textlabel) in Myclass. For example i want that func() of myclass can modify a textlabel of camlive.h.
When i try to make a new object of class Camlive( Camlive^ cml in Myclass, it returns a compile error.
How can i do?
Thanks, regards.
|
|
|
|
|
dodoxor wrote: I want to use it and its components(like a button control or a textlabel) in Myclass. For example i want that func() of myclass can modify a textlabel of camlive.h.
The buttons and labels, generally all controls, are private members by default. Change it to public.
dodoxor wrote: When i try to make a new object of class Camlive( Camlive^ cml in Myclass, it returns a compile error.
How can i do?
<br />
Camlive^ cml = gcnew Camlive();<br />
cml->ShowDialog();
P.S: you should include the Camlive.h header at the top of your class.
#include "Camlive.h"
|
|
|
|
|
I try but it returns some compiler errors...
#ifndef CAMOBJ_H
#define CAMOBJ_H
#include "Camlive.h"
//other include..
#define WIDTH (100)
#define HEIGHT (100)
class Camobj
{
public:
Camobj();
~Camobj(void);
void capture(void);
private:
camaddr_t camaddr;
Camlive^ cml;///compiler error
};
#endif
And in the camobj.cpp
#include "stdafx.h"
#include "Camobj.h"
using namespace System;
using namespace System::IO;
Camobj::Camobj()
{
cml=new Camlive();//compiler error
}
Camobj::~Camobj(void){
...
}
The compiler errors are:
...\Camobj.h(56) : error C2143: syntax error : missing ';' before '^'
...\Camobj.h(56) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
...\Camobj.h(56) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
...\Camobj.h(56) : error C3265: cannot declare a managed 'cml' in an unmanaged 'Camobj'
.\Camobj.cpp(15) : error C2065: 'cml' : undeclared identifier
.\Camobj.cpp(15) : error C2061: syntax error : identifier 'Camlive'
How can i relsolve it?
Thanks regards.
|
|
|
|
|
Hi Guys,
I am developing website that has button controls. When browsing it thru windows xp IE6 or IE7 the view is correct but when browsing it thru mac safari the button will show even I changed the properties to "transparent".
If you encountered this kind of issue I am hoping that you'll gonna share it with me.
Thanks in advance Guys.
Note: This message was mistakenly shared in this category
-- modified at 10:10 Monday 21st May, 2007
hifiger2004
|
|
|
|