Dave, LMAO! I have the same pet hates, but sometimes until somebody says "you don't need to" people's habits remain the same. I remember prefixing ME. in vb4 actually slowed it down coz the stupid environment even resolved the referemce too! so funny. Another one of my pet hates is people not coding with Option Strict. There are lots of others and so little time hahahaha Have a good XMAS mate. Nursey
cnurse
Posts
-
Converting text to date -
Converting text to dateArnie, try this simple change... mydate = Format(cDate(Me.editHireDate.Text.ToString), "Short Date") Nursey
-
RegEx to parse VB.NET source (STILL NEED ANSWER PLEASE)As an excercise in regex, I'm trying to parse various elements of VB Source, so please don't recommend I buy Programmar, or some such tool, coz I won't learn anything. I also have Expresso. OK, I am trying to capture code in a namespace, even if there are nested namespaces, so given the text of... Namespace First Enum FirstEnum MyVal End Enum Namespace Second Enum SecondEnum MyVal End Namespace End Namespace I would expect to be able to get the outer namespace as one capture and the inner namespace as a second capture. Any straightforward pasting of a regex which works, rather than splinters of things you think might work, would be really appreciated. Explanations of how they work would be a bonus, but expresso's analyzer will help me understand to some extent. Thanks guys and have a great XMAS. Nursey
-
Using OpenPrinter/SetPrinter in Win2K3The printer is at my workplace, I just add printer, it's shared from an old server, I looked it up and added it. I can obviously print ok. I can set duplex printing from Word, and print in the normal way. I just have to be able to set duplex on and off from code for some special cases. BTW, would you rather email me to save time on here? chris.nurse@justice.wa.gov.au Thx. Nursey
-
Using OpenPrinter/SetPrinter in Win2K3I captured LPT2, having added a local printer using the same driver, but I get the same result...return code 5 when calling SetPrinter. You said >>OpenPrinter will not connect directly to a network print queue device or driver But everything works really well in terms of reading things about the printer, i.e. its name, location, capabilities etc. Any other thoughts? Could there be some kind of policy enforced by our network people that could affect this. Sorry I don't know too much about domains and server configs. My machine is a Win2K3 box, but it log into a corporate domain. I wotk for the ministry of justice in Perth, Australia, so I reckon you can guess that things are pretty well tightened up in terms of security policies and the like. It doens't change anything if I login into my box as an administrator. I normally log in to the domain and develop. Thanks again. Nursey
-
Using OpenPrinter/SetPrinter in Win2K3This is why I put things like "don't answer unless you know the answer", because every so often then it reduces the clutter and gives a guru a chance to get through! 8-) I will try and map the local port and give it another spin. I would never have found this information other than by your gratious efforts. Many thanks. Nursey
-
Using OpenPrinter/SetPrinter in Win2K3Can I just ask, did you actually step the code and look at all the dll last error codes? If so are you saying you didn't get any occurences of error 5 anywhere? Ta! Nursey
-
Using OpenPrinter/SetPrinter in Win2K3Thank you so much for going to all that effort. However, if y ou find these two lines of kludge... mDeviceMode.dmOrientation = 2 mDeviceMode.dmDuplex = 2 You'll see that I do 'try' to set some properties, BUT, and this is where I have to thank you again. I didn't set the field mDeviceMode.dmFields, to tell the driver it needs to reset those two values, duplex and orientation. So you certainly helped me find a bug in my test case. I am not sure why I get the problem of Access Denied and you don't though. I wonder if its anything to do with the way we setup Win2k3 here. Win2k3 is my box and I guess that's subject to the SOE setup used at work. Perhaps I can do a fix and send you some more code to test, would that be ok. Again, thanks a bunch!:) Nursey
-
Using OpenPrinter/SetPrinter in Win2K3Pardon the big post... I am using the code below to set my printer into Duplex mode, which has to be done via the driver as I sometimes want duplex printing in word, and sometimes I dont. Anyway, regardless of whether you think this can be done with System.Drawing.Printing or not, I want to limit this purely to "why do my API calls not work" as a worthwhile excercise in unmanaged code and interop... Based on many articles I have seen on the web I came up with the class below, but it seems I am also suffering the same woes that every user who ever tried to switch duplex printing on, has suffered, and that it is hard to get it to work. Why am I getting access denied as commented below? Why do the docs say that OpenPrinter has to take a PRINTER_DEFAULTS byref, and when I pass it by ref, every thing breaks at runt time, like, I don't get a printer handle and OpenPrinter causes an Err.LastDllError of 5 (access denied). I think you either know the answer to this one or not. I don't want speculcation and supposition, just hard tested solutions, coz the web is littered with suggestions that dont seem to work. The fundamental problem seems to be that my code doesn't have the right security descriptior to use SetPrinter, even if I log on to my Windows 2003 server as an administrator. Thanks guys, in advance for your patience and efforts! ''' TEST CODE FOR CLASS - put this in a form or module Private Sub Test() Dim lPrinter As New APIPrinter Dim lName As String = lPrinter.DefaultPrinterName lPrinter.Open(lName) lPrinter.DuplexMode = APIPrinter.DuplexOption.LongEdge lPrinter.Close() End Sub ''' CODE FOR CLASS - put this in a spearate class VB file Imports System.Runtime.InteropServices Imports System.Text Public Class APIPrinter Implements IDisposable #Region "WinApi" #Region "Structures" Public Structure PRINTER_DEFAULTS Public pDatatype As String Public pDevMode As IntPtr Public DesiredAccess As Int32 End Structure Public Structure PRINTER_INFO_2 Public pServerName As String Public pPrinterName As String Public pShareName As String Public pPortName As String Public
-
Rotate Text - Find bounding rectanglePlease could you post a full snippet of how to do rotated text as you describe, as that would be useful to know, from my point of view. In olrder apps I have been using LOGFONT stuff and API calls. Nursey
-
MouseWheel events without focusThank you both for your advice, that was just what I needed to hear. I've done quite a bit with subclassing in the past, but as its been a while, and as I would like to know if there is a more ".NET" like way in which this should be done, then it was well worth asking. If I hook into the application message pump, then presumably, as controls run "in process" I will be able to hook into every Windows Forms App that utilises my controls? Many thanks once again. Nursey
-
Expand Collapse #region nodes by shortkeysI have written a VS.NET add-in which helps with regions and collapsing areas in code, like IF THEN ELSE, SELECT CASE END SELECT etc. If you go here: http://www.gotdotnet.com/Community/Workspaces/Workspace.aspx?id=12c54eee-1017-41a6-af3e-42434385d002 you can join my workspace and can even get the source. When its a little further a long I will release it here as an installable package. But for now I am looking for ideas and new features. In its current form its still very useful though. I welcome anybody to join. Nursey
-
MouseWheel events without focusHas anybody found a way to implement a global message trap, so that no matte what window/control has focus, and no matte where the mouse is pointing, you can listen to the mouse wheel roll messages? I have seen mouse driver settings that say send messsages to the window being pointed at, rather than the window with focus. I want to develop several controls that respond to mouse wheel events without having focus, and I dont want to set focus to them just so that I can "hear" the mouse wheel messages either. Any input, pardon the pun, would be great. Nursey
-
Need help on subclassing windowsThanks but I know how to get to the messages. As I said the problem has always been what messages to process. To be specific, what messages do I have to trap and process if I want to take entire responsibility for NC processing/drawing? Do I always have to perform the default processing then do my thing? See? Thanks. Nursey
-
Need help on subclassing windowsHi guys, I've developed in C++ for many years, but more recently have been working in C# and VB.NET. I am developing my own version of themed controls where the user can govern just about any aspect of control drawing, like shape and colour etc. I want to extend this control now to Windows Captions (i.e. Form captions). One thing that I have never fully gained is an understanding of what windows messages to trap, whether to let the default processing always take place, and what values to return. Even when I think I am following the MSDN SDK documention on WM_... notifications I still can't seem to get it right. My problem seems to mainly be in getting setup, i.e. calling GetWindowDC to give me the entire drawing area of the window. Once I have called GetWindowDC I can construct a .NET Graphics object, and later dispose of both after my drawing is complete. I do this and clear the Graphics object to red, so I should see all the non-client area turn red, which happens when the window is first drawn, but after that, as I start to move the window or size it I dont see the DC get consistently filled with red. In summary then, if I could get a control of non-client drawing then I would have raised my programming standard significantly. I would really be immensley greatful if you guys could point me at a definitive guide to subclassing or window's message processing, without recommending 3rd part controls as I am a DIY fanatic! 8-) Also, if any of you can spare some time now and again, perhaps on MSN messenger to chat about this issue that would just be solid gold. I await your responses with baited breath! Thanks all! Nursey
-
Your .NET Add-In WishesDear all, I am getting to grips with writing VS.NET add-ins with a view to publishing an article on here. I am considering making the add-in modular, that it dynamically detects and adds new features rather than having to run the whole installation again, kind of like a snap-in. Anyway, that's by the by. Complete the statement below with a genuine requirement and I will see what I can do to add your wishes into my add-in. I wish I had an add-in (for VB or C#) that...... I have a couple of features in there right now: 1. Select text and wrap in new region Dim a as string a = "hello" becomes... #Region "My Region" Dim a as string a = "hello" #end region 2. Paste a SQL statement in to code and have its individual lines added to a string variable SELECT * FROM mytables ORDER BY 1 becomes... Dim lSQL as string lSQL = "SELECT *" + "\r\n"; lSQL += "... 3. Select member variables of a class and the add-in creates the property let/get code for you 4. Select a database and some tables and the add-in creates classes whose members map to columns on the tables. Any more? Chris Nursey
-
Server Connections/From Add-inDoes anybody know of a way when developing your own VS.NET add-in, to access all the server connections? What I want to do is grab all the tables from the databases listed in their and place them on a treeview in my addin. I know its not the best place to post this, but there is no "CRAZY QUESTION YOU WOULD ASK WHEN WRITING AN ADD IN FOR VS.NET" forum is there guys? (blush) Ta! Nursey
-
Writing a VS.NET AddinI have written an add-in using VB.NET. Yipeee! OK, I've calmed down now! My add-in inserts some code which I wrap in a #region declaration and I want to automatically collapse the region to hide the generated code to keep the developers code in view as much as possible. Has anybody done this? I have tried using the Collapse and OutlineSection but I dont know if I am setting myself up in the text selection object correctly... ' Get a text object Dim lText As TextSelection = CType(applicationObject.ActiveDocument.Selection, TextSelection) ' Move to the beginning of the document so we can iterate over the whole thing. lText.StartOfDocument() If lText.FindPattern(mRegionHeader) Then lText.WordLeft() lText.OutlineSection() lText.Collapse() End If Any ideas would be warmly welcomed. Nursey
-
Checking an objects inheritanceIn the following code pTable is of type CustomerTable, which inherits from DataTable. How can I change the "if" statement to check that pTable is derived from DataTable as the statement currently tests false, because the types are different. I thought I would cast ptable, but the of course that would throw an exception if that cast is invalid. if (pTable != typeof(DataTable)) { throw new EwGeneralException(lStk, EwExceptionID.DdlNotDataTable); } Many thanks for reading. Nursey
-
Inheriting attributesI've developed a simple attribute EwBindSkipAttr which is then used on an abstract member of a class, in the hope that all derived classes which must then implement this member will inherit the attribute on their overriding members. This seems to be correctly implemented...the documentation states that the default is for derived and overriding members to inherit attributes. Here's my simple attribute in use... /// /// Return DDL wrapper for table /// [EwBindSkipAttr] public abstract DataDDL DDL{get;} The problem is that in the derived classes I have behaviour which indicates that the attribute has not been inherited. Any thoughts please? Nursey