|
Such auto-generated classes would likely be useless. There is no substitute for doing it yourself.
|
|
|
|
|
Well I've actually downloaded a class generator that works with Access 2003 and it works perfectly, generated all the classes for me together with methods for adding, updating etc.
|
|
|
|
|
Can you state where you downloaded the class generator or even just it's name? I too am looking for this kind of product.
|
|
|
|
|
|
|
Hi all,
I have a form with datagridview , some datetime pickers and some textboxes. I have modified the code found on this webpage to draw the rows and columns of the datagrid
http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/dc9d3acf-ccf8-457f-ba31-ef09fb357aee/ on the print page . The datagrid is getting drawn on the top of the page. I want to display the textbox contents and datetimepicker contents before the datagrid. Can any1 let me know how to draw the datagrid at the middle of the page with reference to the code in the link.. Thanks,
|
|
|
|
|
There are several code snippets on that link and you do not say which you are trying to use.
However, the grid will be being drawn at coordinates specified somewhere in the code, most probably using DrawRectangle() although that is not certain.
DrawRectangle() most commonly uses a Point structure or a Rectangle structure. So you need to look for a Point parameter that is set to Point(0, 0) , if the grid is at top left, or Point(?, 0) , if it is just somewhere along the top. The same would apply to the first parameter of a Rectangle() if that is what is used.
Find the one that you think draws the grid and experiment with the numbers e.g. try Point(20, 20), run it and if the grid is in a different place then you have found the correct parameter, if not, put it back to what it was before and try another one till you succeed.
Good Luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I have following code in my start button which starts the process.
void BtnStartClick(object sender, EventArgs e)
{
btnStart.Enabled=pdfStopped=xmlStopped=false;
btnStop.Enabled=true;
ThreadPool.QueueUserWorkItem(new WaitCallback(Startup));
}
void Startup(object s)
{
try
{
Start();
timGeneral.Enabled=true;
timGeneral.Start();
}
catch(Exception){}
}
void Start()
{
pdfThread=new Thread(new ThreadStart(pdfDownloadStart));
pdfThread.IsBackground=true;
pdfThread.Start();
xmlThread=new Thread(new ThreadStart(startXMLDownload));
xmlThread.IsBackground=true;
xmlThread.Start();
pdfStThread = new Thread(new ThreadStart(createPdfFileStructure));
pdfStThread.IsBackground = true;
pdfStThread.Start();
}
well i am trying to stop all these running threads in stop button, but i could not achieve it
how can i stop all threads?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
try to avoid using Abort to stop the thread. Use flag to abort the thread.
I got a lot of problem using Abort.
while(isThreadRunning)
{
...
}
to stop it, set isThreadRunning = false;
|
|
|
|
|
Note: you must declare isThreadRunning as volatile, or it will be optimised out...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
well, my friend, if u see i have used
ThreadPool.QueueUserItem(...);
How should i get rid of this to stop all threads.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
You must implement the code, that I sent, in these methods:
pdfDownloadStart
startXMLDownload
Then set isThreadRunning=false to end the thread.
|
|
|
|
|
well, i think u guys did not understand me correctly, bellow is the complete code only for "pdfDownloadStart"
void StartStructureTimer(int time)
{
timStructure=new System.Threading.Timer(new TimerCallback(TimerStructureJob));
timStructure.Change(time,0);
}
void TimerStructureJob(object state)
{
System.Threading.Timer tm=state as System.Threading.Timer;
tm.Dispose();
pdfDownloadStart();
}
void pdfDownloadStart()
{
try
{
signalMessage(string.Format("Searching Server {0} for newly added Files",fdo.FtpServer));
dtList=p.getPdfNotDownloaded();
if (dtList.Rows.Count>0)
{
signalMessage(string.Format("{0} Files Found for Download",dtList.Rows.Count));
fdo.FilesToDownloadList=dtList;
fdo.LocalDownloadDirectory=TempDirectory;
Thread tPdf=new Thread(new ThreadStart(downloadFile));
tPdf.Start();
tPdf.Join();
if (!fdo.DownloadStatus)
{
if (timDownload!=null)
timDownload.Dispose();
signalMessage("Download Failed\r\nretrying in 60 second");
StartTimer(36000);
}
else if (fdo.DownloadStatus)
{
if (timDownload!=null)
timDownload.Dispose();
signalMessage("All Files Downloaded Successfully\r\nretrying in 60 second");
StartTimer(36000);
return;
}
else
StartTimer(36000);
}
else
{
signalMessage("No Files Found\r\nretrying in 60 second");
StartTimer(36000);
}
}
catch(Exception ex)
{
if (!pdfStopped)
{
signalMessage("Failed downloading Files from Remote Server "+ex.Message+"\r\nretrying in 60 second");
StartTimer(36000);
}
else
signalMessage("Failed downloading Files from Remote Server "+ex.Message);
}
}
all methods which runs on those thread has the same functionality. if u see after "60 second" process runs agains.
if i abort or stop the thread still the job runs after 60 seconds.
if u see closly another thread is running to download the files, well i want to stop all these threads, if i use bool value like that still the scheduled process runs.
how can i stop all these threads from calling thread to end?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Hmm.. I think you should redesign it. You start a threadpool, in threadpool you start a thread, in that thread you start a thread again.. wow..
|
|
|
|
|
Try here: How to create and terminate threads[^]
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Since you've set the IsBackground property to true, those threads get aborted when the program closes. Alternatively, you could all pdfThread.Stop, etc.
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hi all,
I am busy developing a custom TCP/IP server. The server has a few events namely, NewTcpData, NewTcpClient and TcpClientDisconnected. At the moment I just want to know of these events.
So I have created the events and all is working fine, but as soon as I call the event from my GUI app, I receive a message stating: Cross-thread operation not valid ...
So normally I would hook the GUI control to the SynchronizationContext .
For example:
context.Send(new SendOrPostCallback((s) => this.textBox1.Text = "Some Data"), null);
So, my question: how can I develop / alter the event(s) (which runs on a separate thread that the main) to not make use of the above technique, and still be able to send / set data to the GUI controls?
Many thanks in advance.
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: So, my question: how can I develop / alter the event(s) (which runs on a separate thread that the main) to not make use of the above technique, and still be able to send / set data to the GUI controls?
If you have to set values to controls that are created by a separate thread, you need techniques like SynchronozationContext , Invoke/BeginInvoke.
BTW, why do you want to do this?
|
|
|
|
|
Thanks for the response Navaneeth.
N a v a n e e t h wrote: BTW, why do you want to do this?
Because, I want to be able to give the user visual confirmation of the following:
New TCP/IP clients that has connectedNew TCP/IP data that has arrivedInform the user when a client has disconnectedUnless you have other suggestions on how this could be achieved?
Thanks again.
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
hi,
need your help to solve this issue..
i have a custom pictureedit control in which i have many custom properties and events. i need to place an image OVER this in another ordinary picture edit and should be able to work on the events in the picture edit in the lower layer.
i'll make it clearer...
in my custom pictureedit i have added a feature to measure the distance between 2 points. now what i need to do is place another image over the main image and while comparing these images should be able to take the measurements from the lower image...
hope you guys understood my issue clearly...
tons of thanks in advance for any help
|
|
|
|
|
I'm not sure I understood correctly. You have 2 controls, one on top of the other, the covered one is a custom control (you wrote it?) and you want mouse events, I suppose, to pass through to the covered control?
If it's your custom control (you have its code) then you can add methods you can call from the top control mouse event handlers then you make those metods call OnMouse.. methods, raise the events or do what you want to do directly in them. If you don't have the code, I think you can send the appropriate message(s) to the covered control using SendMessage[^].
Eslam Afifi
|
|
|
|
|
Thanks eslam...
i tried using the sendmessage function.. but till now i've not been able to implement it successfully..
so can you help me in this...
actually i make the measurement by dragging through the custom pictureedit(i dont have the source code) which is below the covering control
i tried sending the WM_MOUSEMOVE alone & WM_LBUTTONDOWN & MOUSEMOVE together but nothing much happened...
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
private const int WM_MOUSEMOVE = 0x200;
private const int WM_LBUTTONDOWN = 0x201;
private void button2_Click(object sender, EventArgs e)
{
SendMessage(axe.Handle, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
SendMessage(axe.Handle, WM_MOUSEMOVE, IntPtr.Zero, IntPtr.Zero);
}
once again thanks for showing the light..
hope you woulld be able to lead me further
thanks
|
|
|
|
|
What you need is to send a mouse button down message when the mouse is down, mouse move when the mouse is moving and mouse up when the mouse is up. You can experiment to be sure of the message sequence when dragging happens by creating a dummy custom control (or form) with some code similar to the following and figure out the proper message sequence that is generated when you do dragging with it.
protected override void WndProc(ref Message m)
{
Debug.WriteLine(m.ToString());
base.WndProc(ref m);
}
Use this list[^] to facilate analyzing the messages.
Then you can send the appropriate message(s) in the proper event.
By the way, don't send messages with lParam and wParam as IntPtr.Zero since they are supposed to hold modifier keys and mouse coordinates, which you need to make the covered control calculate the distance, otherzise it would calculate zero or some other wrong value since you're notifying it that is the mouse is currently at position (0, 0). See the msdn documentation of WM_LBUTTONDown... to know what to pass to lParam and wParam.
Eslam Afifi
|
|
|
|
|
once again thanks eslam.
i'm still fighting with this.
pls see the log that i got ...
msg=0x201 (WM_LBUTTONDOWN) hwnd=0xb046e wparam=0x0 lparam=0x4b0266 result=0x0
msg=0x7 (WM_SETFOCUS) hwnd=0xb046e wparam=0xd04a4 lparam=0x0 result=0x0
msg=0x8 (WM_KILLFOCUS) hwnd=0xb046e wparam=0x7a045c lparam=0x0 result=0x0
msg=0x111 (WM_COMMAND) hwnd=0xb046e wparam=0x100045c lparam=0x7a045c result=0x0
msg=0xc206 hwnd=0xb046e wparam=0x0 lparam=0x0 result=0x0
msg=0x200 (WM_MOUSEMOVE) hwnd=0xb046e wparam=0x1 lparam=0xffffffffff5d0230 result=0x0
msg=0x2a1 (WM_MOUSEHOVER) hwnd=0xb046e wparam=0x1 lparam=0xffffffffff5d0230 result=0x0
msg=0x202 (WM_LBUTTONUP) hwnd=0xb046e wparam=0x0 lparam=0xffffffffff5d0230 result=0x0
msg=0x215 (WM_CAPTURECHANGED) hwnd=0xb046e wparam=0x0 lparam=0x0 result=0x0
msg=0x2a3 (WM_MOUSELEAVE) hwnd=0xb046e wparam=0x0 lparam=0x0 result=0x0
msg=0x111 (WM_COMMAND) hwnd=0xb046e wparam=0x200045c lparam=0x7a045c result=0x0
but nothing special happened...
no event in the message receiving control was fired..
am I missing anything ?
pls help me on this
thanks
|
|
|
|
|
jamesjk wrote: but nothing special happened...
no event in the message receiving control was fired..
am I missing anything ?
The code was not to fire the events. It was to help you find the right message sequence and the lParam and wParam values to pass (read msdn documentation of those messages to find out the correct values to pass). You send the messages using SendMessage.
So I guess the sequence would be sending,
WM_LBUTTONDOWN in mousedown event
WM_MOUSEMOVE in mousemove
WM_MOUSEHOVER in mousehover (just in case the covered control uses it for something, i don't know. the same applies to WM_MOUSELEAVE)
WM_LBUTTONUP in mouseup
I don't know anything about WM_COMMAND nor 0xc206 (I couldn't find anything about it, maybe it's an undocumented message, i don't know). I think you shouldn't use WM_SETFOCUS and WM_KILLFOCUS. WM_CAPTURECHANGED, i don't know, maybe you should send it right after WM_MOUSEUP in mouseup event.
P.S. I've never tried to simulate something like dragging before but I did try sending simple messages before. I don't know much so you should experiment more. And study sequences generated from cases like mousedown, move, leave the control, re-enter the control, move, mouse up... (cases like that) to ensure you get the desired result in both normal cases and extreme cases. And you're welcome.
Eslam Afifi
|
|
|
|
|