|
I tried with Admin user, local System account and tried direct path also like
"\\server\public_data\hello.txt" but no use. It has problem when running as a service in win2003k and as standalone no problem.
do anyone know how to give more permissions to services in win2003k os?
|
|
|
|
|
I am new to windows programming, and am using Visual Studio .Net 2003.
I have a standard managed form which contains a number of data entry fields (textboxes, radio buttons etc), and a couple of buttons.
One of the buttons (labelled Save) activates an event handler that calls two functions. The first function will perform some validation on the data entered in the form, and then displays a message on a second smaller form with an OK button. This OK button closes the form. The second function then formats some of the data, and will eventually write it to a file.
How do I stop the second function running until after the OK button on the form displayed by the first function is clicked ? Or, in other words, how do I stop the 2nd function from running until the first is complete.
The program so far is listed below, and the event handler concerned is called collegeForm::buttonSave.
Many thanks
#using
#using
#using
#using
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
__gc class collegeForm : public Form
{
public :
collegeForm();
private :
Label *labelSurname;
Label *labelForename;
Label *labelGender;
Label *labelDateOfBirth;
Label *labelAccomodation;
Label *labelSupportCode;
Label *labelCourseCode;
TextBox *surname;
TextBox *forename;
TextBox *courseCode;
TextBox *dateOfBirth;
ComboBox *supportCode;
GroupBox *gender;
RadioButton *male;
RadioButton *female;
GroupBox *accomodation;
RadioButton *parentalHome;
RadioButton *lodgings;
RadioButton *hallsOfResidence;
Button *save;
Button *clear;
MainMenu * mainMenu;
void buttonSave(Object *Sender, EventArgs *Args);
void buttonClear(Object *Sender, EventArgs *Args);
Int32 validateForm(void);
void formatNames(void);
};
__gc class errorMessage : public Form
{
public :
errorMessage();
errorMessage(String *);
private :
Label *message;
Button *ok;
void buttonOK(Object *Sender, EventArgs *Args);
};
errorMessage::errorMessage()
{
}
errorMessage::errorMessage(String * errorMessage)
{
this->Text = S"Error Message";
message = new Label;
message->Text = errorMessage;
message->Location = Point(25,100);
this->Controls->Add(message);
ok = new Button;
ok->Location = Point(180,120);
ok->Text = "OK";
ok->Click += new EventHandler(this,buttonOK);
this->Controls->Add(ok);
}
void errorMessage::buttonOK(Object *Sender, EventArgs *Args)
{
Close();
}
collegeForm::collegeForm()
{
this->Text = S"College Enrollment Database";
labelSurname = new Label;
labelSurname->Text = S"Surname";
labelSurname->Location = Point(25,100);
this->Controls->Add(labelSurname);
labelForename = new Label;
labelForename->Text = S"Forename";
labelForename->Location = Point(25,150);
this->Controls->Add(labelForename);
labelGender = new Label;
labelGender->Text = S"Gender";
labelGender->Location = Point(25,200);
this->Controls->Add(labelGender);
labelDateOfBirth = new Label;
labelDateOfBirth->Text = S"Date Of Birth";
labelDateOfBirth->Location = Point(25,250);
this->Controls->Add(labelDateOfBirth);
labelAccomodation = new Label;
labelAccomodation->Text = S"Accomodation";
labelAccomodation->Location = Point(25,300);
this->Controls->Add(labelAccomodation);
labelSupportCode = new Label;
labelSupportCode->Text = S"Support Code";
labelSupportCode->Location = Point(25,350);
this->Controls->Add(labelSupportCode);
labelCourseCode = new Label;
labelCourseCode->Text = S"Course Code";
labelCourseCode->Location = Point(25,400);
this->Controls->Add(labelCourseCode);
surname = new TextBox;
surname->Location = Point(125,100);
surname->Width = 200;
this->Controls->Add(surname);
forename = new TextBox;
forename->Location = Point(125,150);
forename->Width = 200;
this->Controls->Add(forename);
courseCode = new TextBox;
courseCode->Location = Point(125,400);
courseCode->Width = 100;
this->Controls->Add(courseCode);
dateOfBirth = new TextBox;
dateOfBirth->Location = Point(125,250);
dateOfBirth->Width = 200;
this->Controls->Add(dateOfBirth);
supportCode = new ComboBox;
supportCode->Location = Point(125,350);
supportCode->Width = 230;
supportCode->Items->Add(S"No Known Disability");
supportCode->Items->Add(S"Dyslexia");
supportCode->Items->Add(S"Blind or Partially Sighted");
supportCode->Items->Add(S"Deaf or Impaired Hearing");
supportCode->Items->Add(S"Mobility Difficulties or Wheelchair User");
supportCode->Items->Add(S"Personal Care Support Required");
supportCode->Items->Add(S"Mental Health Difficulties");
supportCode->Items->Add(S"Unseen Disability - Diabetes, Asthma");
supportCode->Items->Add(S"Two Or More Of The Above");
supportCode->Items->Add(S"Other Disability Not Listed");
supportCode->Text = S"No Known Disability";
this->Controls->Add(supportCode);
gender = new GroupBox;
gender->Location = Point(125,175);
gender->Size = Drawing::Size(300,55);
Controls->Add(gender);
male = new RadioButton;
male->Location = Point(25,20); // These are coords in group box
male->Text = S"Male";
gender->Controls->Add(male);
female = new RadioButton;
female->Location = Point(150,20);
female->Text = S"Female";
gender->Controls->Add(female);
accomodation = new GroupBox;
accomodation->Location = Point(125,275);
accomodation->Size = Drawing::Size(450,55);
Controls->Add(accomodation);
parentalHome = new RadioButton;
parentalHome->Location = Point(25,20);
parentalHome->Text = S"&Parental Home";
accomodation->Controls->Add(parentalHome);
lodgings = new RadioButton;
lodgings->Location = Point(150,20);
lodgings->Text = S"Lodgings";
accomodation->Controls->Add(lodgings);
hallsOfResidence = new RadioButton;
hallsOfResidence->Location = Point(275,20);
hallsOfResidence->Text = S"&Halls Of Residence";
accomodation->Controls->Add(hallsOfResidence);
save = new Button;
save->Location = Point(175,500);
save->Text = S"&Save";
save->Click += new EventHandler(this,buttonSave);
this->Controls->Add(save);
clear = new Button;
clear->Location = Point(350,500);
clear->Text = S"&Clear";
clear->Click += new EventHandler(this,buttonClear);
this->Controls->Add(clear);
mainMenu = new MainMenu();
MenuItem *menuFile = mainMenu->MenuItems->Add("&File");
menuFile->MenuItems->Add("&Validate");
menuFile->MenuItems->Add("&Save");
menuFile->MenuItems->Add("&Clear");
menuFile->MenuItems->Add("-");
menuFile->MenuItems->Add("&Exit");
MenuItem *menuHelp = mainMenu->MenuItems->Add("&Help");
menuHelp->MenuItems->Add("&About");
Menu = mainMenu;
}
void collegeForm::buttonSave(Object *Sender, EventArgs *Args)
{
validateForm();
formatNames();
}
void collegeForm::buttonClear(Object *Sender, EventArgs *Args)
{
surname->Text = S"";
forename->Text = S"";
courseCode->Text = S"";
dateOfBirth->Text = S"";
supportCode->Text = S"";
male->Checked = false;
female->Checked = false;
parentalHome->Checked = false;
lodgings->Checked = false;
hallsOfResidence->Checked = false;
}
Int32 collegeForm::validateForm(void)
{
errorMessage * em = new errorMessage("This is a test");
em->Size = System::Drawing::Size(400,200);
em->Show();
return(1);
}
void collegeForm::formatNames(void)
{
String * left;
String * right;
String * temp;
if (surname->Text->Length > 1)
{
temp = surname->Text;
left = temp->Substring(0,1);
right = temp->Substring(1,temp->Length-1);
left = left->ToUpper();
right = right->ToLower();
temp = String::Concat(left,right);
surname->Text = temp;
}
if (forename->Text->Length > 1)
{
temp = forename->Text;
left = temp->Substring(0,1);
right = temp->Substring(1,temp->Length-1);
left = left->ToUpper();
right = right->ToLower();
temp = String::Concat(left,right);
forename->Text = temp;
}
}
int __stdcall WinMain()
{
collegeForm *cf = new collegeForm();
cf->Size = System::Drawing::Size(600,600);
Application::Run(cf);
return 0;
}
Simon Cornish
Simon Cornish
|
|
|
|
|
Simon Cornish wrote: em->Show();
try this:
em->ShowDialog(this); //this will make a Modal dialog
If you are trying to display only error message, why you don't use:
MessageBox::Show()
|
|
|
|
|
Many thanks - all sorted.
|
|
|
|
|
How to attach an assembly dll to project in C++ for VC NET and use its namespaces?
9ine
|
|
|
|
|
9ine wrote: How to attach an assembly dll to project in C++ for VC NET and use its namespaces?
You need to add a reference.
|
|
|
|
|
How to do it?
Piece of code in VC++ please or where to plug it in in proj settings and how to use it then?
It is about the article:
DirectX >> General
Capture Sample with DirectX and .NET By Blas5
The source code for his application to use directx.capture.dll and dshownet.dll is in VB and it uses imports DirectX.Capture
but I need it in VC++ to use something like using namespace.
9ine
|
|
|
|
|
Which version of VC++ are you using?
In VC++ 2005, take [References] from the [Project] menu and click on [Add new reference]. You need to put the Project name in focus in Solution Explorer to get the required menu items in the [Project] menu.
|
|
|
|
|
try this:
#using "directx.capture.dll"
|
|
|
|
|
I use VC 2003 and it is
#using "directx.capture.dll"
using namespace DirectX::Capture;
9ine
|
|
|
|
|
Hello!
I need to make a skip list in my application and I decided to take code from Robert Sedgewick's book "Algorithms in C++", but faced one serious problem: the insert function sometimes failes. I don't know why. Here is it:
const int lgNmax = 10;
template <class Item, class Key>
class SkipList
{
private:
struct node{
Item item;
node **next;
int sz;
node(Item x, int k)
{
item = x;
sz = k;
next = new node*[k];
for(int i = 0; i < k; i++)
next[i] = 0;
}
};
typedef node *link;
link head;
Item nullItem;
int lgN;
...
int _randX()
{
int i, j, t = rand();
for(i = 1, j = 2; i < lgNmax; i++, j += j)
if(t > RAND_MAX / j)
break;
if(i > lgN)
lgN = i;
return i;
}
void _insert(link t, link x, int k)
{
Key v = x->item.Key();
link tk = t->next[k];
if(!tk || v < tk->item.Key()){
if(k < x->sz){
x->next[k] = tk;
t->next[k] = x;
}
if(k == 0)
return;
_insert(t, x, k - 1);
return;
}
_insert(tk, x, k);
}
public:
SkipList()
{
head = new node(nullItem, lgNmax);
lgN = 0;
srand((unsigned int)time(NULL));
}
void Insert(Item v)
{
_insert(head, new node(v, _randX(), lgN);
}
...
};
And the problem is with the 'if(!tk || v < tk->item.Key()){' line (marked with comment). The problem is that the tk sometimes becomes 0xfdfdfdfd. I can't understand why and how to avoid this. It happens at the first iteration of _insert() when t = head. And this usually happens at 300th - 600th insertion. Could you help me to remove the bug?
Thank you in advance!
|
|
|
|
|
You should ask this in the Visual C++[^] forum. This is the C++/CLI forum.
|
|
|
|
|
Can you confirm you have set this line correctly?
It appears the 'node' contructor takes two argument, and the _insert takes three, but your parentheses are mismatched here?
_insert(head, new node(v, _randX(), lgN);
Did you mean
_insert( head, new node( v, _randX() ), lgN );
and making that change, does it work?
No shirt, no shoes, no brains, no service.
|
|
|
|
|
That was my mistake... And here is the real solution:
void _insert(link t, link x, int k)
{
Key v = x->item.Key();
if(k >= t->sz){
_insert(t, x, k - 1);
return;
}
link tk = t->next[k];
if(!tk || v < tk->item.Key()){
if(k < x->sz){
x->next[k] = tk;
t->next[k] = x;
}
if(k == 0)
return;
_insert(t, x, k - 1);
return;
}
_insert(tk, x, k);
}
|
|
|
|
|
There is a international exhibition center which has 40 floor, and 10 elevator.
Constrain condition
1. The movement rule of the elevator:
E0.E1: can reach any floor of the building
E2.E3: can reach 1 and 25~40 floor
E4.E5: can reach 1~25 floor
E6.E7: can reach 1 and the even number of 2~40 floor
E8.E9: can reach the odd number of 1~39 floor
2. The maximum weight that every elevator can support is K people (suggest: people number is range from 10 to 18)
3. Before the simulation, every elevator is randomly parked in random floor in accordance with its movement rule, empty inside.
4. After the simulation, N (N=0~1000) people arrive 1 floor of this international exhibition center in M minutes randomly, and begin the activity of embark.
5. The floor that every passenger wants to arrive is random at the first time, and he waits the coming of the elevator at proper parking place.
6. After every passenger arrive the specified floor by proper elevator, settle (rest for a while) 10~120sec randomly, and go on going another floor randomly, the rest may be deduced by analogy. After every passenger embark the elevator L times (every people has the different L value, when a passenger come into being, this value is randomly specified from 1 to 10),the L+1 times will be down to 1 floor and finish the activity. The simulations also finish.
7. The velocity of the elevator is S second per floor (S=1~5), every people getting up or down time is T second (T=2~10).
8. The direction of the elevator is judged by the demander who first request, the later demander is not allowed to change the current direction of elevator, unless it is the empty elevator which is still not requested.
9. When there is passenger in some floor push the requesting button, the nearest to the passenger and satisfy term 8 and fastest elevator is preferential.
10. Not allow the elevator surpass its supporting ability.
Developing result:
1. The event created cycle is 1 second; every time can create 0 or more events.
2. Pseudo-random number producer specifies every random event.
3. Design a interface that can understand easily, dynamically display carrying passenger and working situation of the elevator, dynamically display passenger settle situation of every floor and request embark situation; dynamically display the time from the beginning of the simulation to current time.
4. You should display the passenger and his requested floor. For example, 12-32 express the passenger whose identity is 12 want to go 32 floor.
5. Statistical list the working and idle time of every elevator; statistical list the waiting time that every people ask for embark elevator; display these times after the simulation.
6. K.N.M.S.T parameters should be input from command line.
|
|
|
|
|
anyone who doesn't want to provide help please don't disturb
|
|
|
|
|
you suck...
my last answer[^] is still applying...
and there's no need neither to cross post the forums to how an answer... you won't have any until the question is not satisfying...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20] | soon : [VisualCalc 3.0]
|
|
|
|
|
If you don't want to code this on your own, you could pay someone to do it, perhaps a classmate who's in need of money.
|
|
|
|
|
#ifndef M1
#define M1
// This is a copy of m1.h
// "EXPORTING STATIC AND NON-MEMBER FUNCTIONS"
// I have three questions that have me foxed. I am very new to c++.net but not c++.
// All code compiled CLR/pure 2005 beta
// A) Need to export Plain c++ functions (not "C" as need function overloading.)
// from a dll so they can be used in the managed exe and other managed dll's
// ( Class's are easy just make them public, but what to do about non
// member functions as you can't use public keyword.
// B) Would also like to export static memeber functions.
// C) On a similar vain I want to export static data
/* would like this to know how this can be made to work
both with and without setting the line below ie for
both gc and nongc class's
*/
//#define TRY_THIS_ALSO
namespace BL {
static void junk2();
#ifndef TRY_THIS_ALSO
public ref class foo {
#else
public class foo {
#endif
public:
int cnt;
};
#ifndef TRY_THIS_ALSO
public ref class bunmanaged {
#else
public class bunmanaged {
#endif
int i;
public:
static foo myStatic ;
bunmanaged(){}
static void junk();
};
};
#endif
//CLI standard
//http://download.microsoft.com/download/9/9/c/99c65bcd-ac66-482e-8dc1-0e14cd1670cd/C++-CLI%20Standard.pdf
//Seems to suggest I might be doomed as can't use public
/* this is a copy of matching m1.cpp
#include "stdafx.h"
#include "m1.h"
namespace BL {
void junk2() {
}
#ifdef TRY_THIS_ALSO
foo bunmanaged::myStatic ;
#endif
void bunmanaged::junk() {
}
};
*/
/* In my other managed class in other dll/exe I have
#using "../Debug/my3Lib.dll"
using namespace BL; //This seems to work so far as the fact that intelisense likes it
I tried many variations on the following.
#using "../Debug/my3Lib.dll"
[DllImport("../Debug/my3Lib.dll",EntryPoint = "BL::bunmanaged::junk()")]
void bunmanaged::junk();
...
public ref class myLibControl : public System::Windows::Forms::UserControl
{
public:
myLibControl(void) {
InitializeComponent();
BL::bunmanaged::myStatic.cnt = 3;
BL::junk();
BL::junk2();
*/
Thanks barry
|
|
|
|
|
The microsoft web site says.
Compiler Warning (level 1) C4272
Error Message
'function' : is marked __declspec(dllimport); must specify native calling convention when importing a function.
It is an error to export a function marked with the __clrcall calling convention, and the compiler issues this warning if you attempt to import a function marked __clrcall.
The following sample generates C4272:
Copy Code// C4272.cpp
// compile with: /c /W1 /clr
__declspec(dllimport) void __clrcall Test(); // C4272
__declspec(dllimport) void Test2(); // OK
|
|
|
|
|
Hi All
i wrote one ISAPI Extension.i have to test it for all possible requestlike chunked, with content-length and non-content length.
presently i want to test it for chunked request. is there any tool or techniques by which i can send chunked request. i think it's very difficult to generate a chunk request.
i anyone know how i can do that or have some code snippet then let me know.
Thanks in advance
|
|
|
|
|
How can I convet string to a desired integer??? Using C++
for example:
January=1
February=2
March=3
......
Hope you can help me
|
|
|
|
|
|
You also canuse :
Int32 January = Convert::ToInt32("1");
|
|
|
|
|
<font color=blue>enum</font> months {
January = 1,
February = 2,
March = 3,
<font color=green>
December = 12
};
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20]
|
|
|
|
|