|
Hi,
Using VB.NET. I'm a beginner so please be gentle..
I am trying to overdraw A ListBox control, among others, so that they have a solid 3 pixel border. Currently I am doing this by creating a customcontrol inheriting from the specific windows control i.e. CustomListBox, inherits ListBox... then handling the WndProc and looking for the WM_Paint message.
I am then calling the MyBase.OnPaint.. this is to handle all of the item drawing, and on TextBox the text drawing stuff etc... then drawing over the 3DBorder with a solid border of the required colour.
However when I do this and the control is resized it flickers quite badly and I want to stop the flickering.
I have tried overriding the NC_PAINT message, which works very nicely, until the list box needs scroll bars.. then I am getting very strange results..
I've also tried setting the styles property to DoubleBuffer.. but that didn't seem to make a difference.
I'm not even sure that I'm going about this in the right way. Does anyone know of a way to do this sort of thing correctly, or a way to stop the flickering.
Any help at all would be appreciated. Even if it's to point me in the direction of a guide or documentation to custom drawing controls
Regards and thanks in advance,
Rig.
|
|
|
|
|
I'm sorry that I cannot be of any help, but I would be very grateful for anything you may have learned in changing the border color of a textbox.
Many thanks
Matt
|
|
|
|
|
How can I load load icon from a file into my vb.net program. i.e. if I use a tree view control it would be nice to get the icon for a specific file type that is registered for that file and load it dynamically into an image list so I can display the correct icon for that file in the tree view. Thanks in advance
Jim
|
|
|
|
|
|
Hi,
I need to call a function in a library that is niether a COM or .NET. (Similar to API but not an API function).
I don't need to pass parameters to this function.
What do I need to do exactly? Do I need to add a reference? (I guess not). How will the run-time know where it is?
Regards,
Ekareem
|
|
|
|
|
Hello everybody!
Can some one please tell me what am i doing wrong here?
Set SearchRS = MSLog.Execute("SELECT OrderNumber, OptOut, DateIn FROM OptOutLog WHERE DateIn between 4/1/2003 AND 4/30/2003")
This does not return any records and i know that there are records with dates in that range
I have tried <= => nothing works
Thank you very much!!!
ilya P.
|
|
|
|
|
i think you need ticks around the dates
Set SearchRS = MSLog.Execute("SELECT OrderNumber, OptOut, DateIn FROM OptOutLog WHERE DateIn between '4/1/2003' AND '4/30/2003'")
and if you are using access you might need the pound signs (#)
Set SearchRS = MSLog.Execute("SELECT OrderNumber, OptOut, DateIn FROM OptOutLog WHERE DateIn between #4/1/2003# AND #4/30/2003#")
also, you might want to add the time, like.... '04/01/2003 00:00:00' AND '04/30/2003 23:59:59'
Steve
|
|
|
|
|
Dear Steve
Thank you very much!!! I tried with ' around before, but i completely
forgot about # signs.
It works like magic now.
Thank you
Ilya P.
|
|
|
|
|
iluha wrote:
Thank you very much!!! I tried with ' around before, but i completely
forgot about # signs.
Access uses the # sign where SQL Server uses a single quote.
-Nick Parker
|
|
|
|
|
I'm building a Service in VB.NET: It's basically watching for a file to appear in a directory; when it does, it processes that file into a database. Depending on the size of the data file, this process can take some time.
What I want to be able to do is prevent the Service Control Manager (SCM) from shutting my service down while it's busy. What is the best way to do this? I tried setting Me.CanStop to false on the fly, but found that it can't be changed while the service is running.
The one idea I've had so far is to create a boolean called isBusy that is set to true while processing and false while idle. Then, in the OnStop event do the following to prevent the stop until the task is done:
Do While isBusy
DoEvents
Loop
But, then what happens when this exceeds the timeout that the SCM has? The SCM reports an error, but does the service eventually shutdown? My main concern is finding a way for my user to shut the service down without shutting down in the middle of a task.
Thanks for any insight.
|
|
|
|
|
I don't think that you can prevent the service form being shutdown.
If all you are trying to do is preserve the integrity of the data that you are importing you can look into other ways to do this, perhaps locally creating the record set then adding it to the DB (this might be faster then adding it to the DB as you read from the file), or try adding the data to the DB inside of a transaction. That way it can be aborted if someone decides to stop in the middle and you won't get partial processed data.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Once the SCM signals the service to shutdown, it will, event if the SCM doesn't "see" it happen. I recommend you don't use a simple boolean, however. Look at the System.Threading namespace, specifically Mutexes or Monitors. These are much safer to use. Basically, the file parsing / processing procedure and the code snippet you wrote above share a mutex or semaphore (a WaitHandle in most cases in .NET) You would obtain an exclusive lock on the mutex / semaphore before doing all your processing. If close is called it'll wait till it can receive an exclusive lock. The reverse is also true, but that processing proc won't be called when the service is shutdown obviously. Basically, however gets an exclusive lock on the mutex first wins and the other(s) wait until they can get an exclusive lock before running their code. This is far more safe.
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
Thanks for the advice. Let me see if I understand the basic concept:
At the beginning of the processing section that I want to be "uninterruptible":
Try<br />
Dim M As New Threading.Mutex(True, "myUniqueCode")<br />
' do the processing<br />
Finally<br />
M.Close()<br />
End Try
In the OnStop event
Dim M As New Threading.Mutex(True, "myUniqueCode")<br />
Do Until M.WaitOne(1000, False)<br />
Loop<br />
M.Close()<br />
'do any resource cleanup here
Related question: What is the correct way to shut down my service from within it's own code? For example, if my service encounters a condition that tells it to end (other than the SCM's stop command), how does it shut itself down cleanly? I read somewhere that the END command is considered bad form for services.
Long term, my application will consist of multiple services (each with their own uninterruptable sections). Some will be more sensitive to this issue than others. I'm thinking of creating an applet that will send a message to each of them and they will shut themselves down when they are free from whatever they were doing). The applet can show the status of each one in turn so the user can watch them shutting down and know when it is safe to proceed.
|
|
|
|
|
Actually, this probably wouldn't work. Since you're requesting initial ownership in the same thread, the call to WaitOne() (or its equivalent in the constructor that requests initial ownership) will pass. Read the docs on Mutexes and you'll see that a thread can request access to a Mutex multiple times without blocking. I'm not sure how you're threading your file processing procedure (which is a good idea to do, btw), but doing them in the same thread would not work. Instead, take a look at the SyncRoot keyword in Visual Basic. Basically, declare a shared variable somewhere in your class:
Private Shared syncRoot As Object = New Object()
Then, in both methods, you can do the following (although there's no timeout, but these keywords boil down to a Monitor at compile time, so take a look at that for more details):
SyncLock (syncRoot)
' Do work
End SyncLock
Hope this helps.
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
Hi,
I would suggest a different approach. Let the service start a separate program with the file name as a parameter. Let that program deal with the database as long as it needs to.
By doing this your service can do its new function regardless of the the file size.
Of course I am assuming that a service can launch an application - I may be wrong.
Regards
Ekareem.
|
|
|
|
|
I am just wondering if anyone else has had this problem. I made a little app, that i put a web browser control on it, and navigated to a page, say www.thecodeproject.com. If I then set the ShowInTaskbar property in code somewhere, the web browser control disappears and i cannot get it to come back. I have tried like browser.show, browser.visible = true, etc. Any suggestions or has anyone else had this problem?
|
|
|
|
|
How can i print the contents of the listview control(including header) to printer using VB.NET,
can anybody please help me with code
Thank U
|
|
|
|
|
I am looking for al line-control for VB. (maybe VB.NET - But I still haven't switched to)
Ideally it would work like the "connections" between shapes in Excel.
The line should present a connection between some self-made controls. The user should be able to edit the lines, so that he/she can make a little network (1 to 2 screens full).
Up to now I've done some experiments with the existing line:
Determing the distance between the click(x/y) and a line => self-made "click" event ...
Thanks in advance.
Friedrich
|
|
|
|
|
Hi Everybody,
I need your help regarding Subclassing in VB.NET. I am developing a project in which I am using Web Browser Control as Winodws Explorer. Means I am providing most of the functionalities of Windows Explorer in my Web Browser control through my application.
I would like to SubClass the Web Browser Control and want to get the DELETE notification when user clicks on a button provided by interface. Or when user Right Click and chooses the "Delete" option from popup menu provided by Windows. Or, in Windows XP, user clicks the left panel entry "Delete this file" option.
I try to Subclass the Web Browser Control and try to get the DELETE notification. But application is not stable and also I am not able to trap the notification. While debuging or EXE of the application crashes as soon as I try to enter the mouse in the Web Browser Control.
Please, could you help me in this context?
I shall be very thankful to you for the same. Waiting for you early reply.
Best regards,
Vilas Shewale
|
|
|
|
|
Subclassing in VB Classic is notoriously unforgiving. One time I had a program with a subclass that brought down the whole computer whenever it was run.
I've had a lot of experience with subclassing in both VB Classic and C# so I might be able to help you.
Could you post your code? I might be able to spot a bug in it for you.
By the way, subclassing is much more stable when using an already-compiled dll like the SubClassing and Timer Assistant available at vbAccelerator[^].
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
Hi,
Thank for your most earliest reply i ever had. I shall post the code to your email account. Please do the needful.
And i offer my deepest condolence for the crash of the machine.
Best regards,
Vilas Shewale
|
|
|
|
|
Hi,
Did you get anything regarding my problem? I'm waiting for your reply.
Best regards,
Vilas Shewale
|
|
|
|
|
villly wrote:
Did you get anything regarding my problem? I'm waiting for your reply.
Strange - I sent an email to you both direct and through CP the same night you posted here first. CP had an error, but the direct email wasn't returned, so I thought I had gotten through. Anyway, here it is.
**********EMAIL***************
Your problem probably has to do with the fact that the listview control that shows the files/folders is the one getting the delete message rather than the WebBrowser window which is its parent.
Fix: Get the child window's handle and the enumerate the windows to find a window with the classname "SHELLDLL_DefView". If this window doesn't recieve the delete messages, enumerate its child windows to find a window with the classname "SysListView32" and subclass it. Hefty fix, huh?
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
Hi,
Thank you very much for your help. It's working properly. I subclass "SysListView32" object of Web Browser Control and getting the messages from it throught VB.NET's "System.Windows.Forms.NativeWindow".
Thank you very much for your help.
Best regards,
Vilas Shewale
|
|
|
|
|
Hi,
I am facing the same problem again but in different way now. I subclass "SysListView32" object to get the messages. It's working for other messages like mouse move, mouse over, etc. But I am not able to trap DELETE notofication in the same object.
MSDN help says the WM_DELETEITEM message is sent to the owner of a list box or combo box when the list box or combo box is destroyed or when items are removed by the LB_DELETESTRING, LB_RESETCONTENT, CB_DELETESTRING, or CB_RESETCONTENT message. So I try to trap the same message in my code. I am not able to get the DELETE notification by "SysListView32" object.
Could you help me in the same context? I want a message which will trap the DELETE message as soon as user will click on "Right click\Delete" or "Delete this file" from the left panel of Web Browser control.
Thank you very much for your help. I look forward to hear from you very soon.
Best regards,
Vilas Shewale
|
|
|
|