Jump to content
Xtreme .Net Talk

DPrometheus

Avatar/Signature
  • Posts

    50
  • Joined

  • Last visited

About DPrometheus

  • Birthday 06/01/1989

Personal Information

  • Occupation
    Application developer for local hospital
  • Visual Studio .NET Version
    Visual Studio.NET 2005 / 2008 / 2010 Professional
  • .NET Preferred Language
    VB.NET, C++/CLI, JScript

DPrometheus's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. You can connect to several databases with dataproviders in .NET. See http://msdn.microsoft.com/en-us/library/s7ee2dwt%28VS.71%29.aspx for more information about data providers. ConnectionStrings for the several databases can be resolved at www.connectionstrings.com/
  2. What about: CBoolProperty m_bHeight = false; [/Code] ??
  3. What if you take the code from Chetan Chudasama's weblog and recompile it against the vs.net 2008 (v9) libraries. Then you should be able to use that in the codeplex project for example Chetan opens Visual Studio v8 (2005) from his code using EnvDTE80; ... Type type = System.Type.GetTypeFromProgID("VisualStudio.DTE.8.0"); [/Code] If you replace these with the vs.net 2008 equivalents (version 9) It might do the trick? ~DP
  4. in the ElseIf vals(0) = "Drops" Then Me.txtDrops.Text = vals(1) End If you have to have an additional loop which checks on a vbNewLine (or just empty line). Before you encounter that (or a EndOfFile) you can add each sentence as an item. i.e. Dim FileName As String FileName = "Data.dat" Dim srBestiary As System.IO.StreamReader = New System.IO.StreamReader(FileName) Dim line, vals() As String Do line = srBestiary.ReadLine If line Is Nothing Then Exit Do vals = line.Split(vbTab) If vals(0) = "Name" Then Me.txtName.Text = vals(1) ElseIf vals(0) = "Level" Then Me.txtLevel.Text = vals(1) ElseIf vals(0) = "Drops" Then ' Add this piece here while(line = srBestiary.ReadLine) if string.IsNullOrEmpty(line) exit while Me.txtDrops.Text = line end while End If Loop srBestiary.Close() srBestiary = Nothing however you should also append the text or something, since now you are replacing it and thus the textbox (assuming txtDrops is a textbox) will only read the last line of the document, thus 'Raw Meat'. You can change this for example by replacing Me.txtDrops.Text = line with Me.txtDrops.Text &= vbNewLine & line ~DP
  5. Hi there, Do you want the textbox to consist of scrollbars? Since then you don't have to add them, you can then dis-/enable them in the property page of the rtb. (named Scrollbars and you can set it to both, horizontal, vertical, force horizontal etc.) Otherwise you can add multiple controls to a usercontrol or add them to a panel. Here you can add the VScrollBar. Now you can dock it to the right (as default in most programs) and handle the scroll event (with e.newvalue and e.oldvalue in the event arguments you can determine how far you want your controls moved) You can then adjust the location property of the controls contained within the panel or usercontrol. ~ DP
  6. VB.NET Private Declare Function SendMessageByString Lib "user32.dll" Alias "SendMessageA" _ (ByVal hwnd As IntPtr, _ ByVal uMsg As Int32, _ ByVal wParam As IntPtr, _ ByVal lParam As String) As Integer Private Const WM_SETTEXT As Int32 = &HC Private Declare Function SendMessageByInt Lib "user32.dll" Alias "SendMessageA" _ (ByVal hwnd As IntPtr, _ ByVal uMsg As Int32, _ ByVal wParam As Int32, _ ByVal lParam As Int32) As Integer Private Const WM_GETTEXTLENGTH As Int32 = &HE Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As IntPtr Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" _ (ByVal hWnd1 As IntPtr, _ ByVal hWnd2 As IntPtr, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String) As IntPtr Public Function GetHandle(ByVal ClassName As String) As IntPtr Dim hwnd As IntPtr = FindWindow(ClassName, Nothing) hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Edit", Nothing) If (Not hwnd.Equals(IntPtr.Zero)) Then Return hwnd Else Return IntPtr.Zero End If End Function Public Sub SetNewText(ByVal hwnd As IntPtr, ByVal txt As String) If (Not hwnd.Equals(IntPtr.Zero)) Then Call SendMessageByString(hwnd, WM_SETTEXT, IntPtr.Zero, txt) End If End Sub ~DP
  7. Open notepad with System.Diagnostics.Process.Start("notepad.exe") [/Code] Then you can get the window handle and send a WM_SETTEXT message to set the text. also you could write to a (temporary) text file and start notepad and the textfile as second parameter: [Code] System.Diagnostics.Process.Start("notepad.exe", "mydocument.txt") [/Code] ~ DP
  8. Update =-=-=- The problem grew today in size as I also need a reference to some document objects. Those can be set with a document manager (custom class like above patient manager with additional functions). But the references are lost in the VBA code (if I set it within the .NET assembly), same goes for the other way 'round. Anyone has tips for a workaround or something? thanks in advance, ~DP
  9. As iMP said, you should get something like this: vb.NET Private Function CheckControls(ByVal control As Control) As Control For Each c As Control In control.Controls If c.Controls.Count > 0 Then CheckControls(c) If TypeOf c Is Label Then ' Do something with c Return c End If Next Return Nothing End Function [/Code] or C# [Code] private Control CheckControls(Control control) { foreach (Control c in control.Controls) { if (c.Controls.Count > 0) CheckControls(c); if (c is Label) { // Do something with c return c; } } return null; } [/Code] ~DP
  10. Thanks for your opinion thus far. In the load event of the Main Form I call this line in the .NET App: _wDoc = EcAppPanel1.LoadDocument(My.Computer.FileSystem.CurrentDirectory & "\Spec.dotm") which opens the file in the hosted Word Instance. In this macro enabled template I got only one function like this: Sub AutoNew() AddIns.Add ("K:\mso\AppInApp\Word07Def.dotm") End Sub [/Code] Which adds another macro enabled template to the word instance. This is done like this so the template stays active even after switching documents. This Word07.dotm template modifies the ribbon together with some additional functionality. For example [Code] Sub AdresseringButton_Click(control As IRibbonControl) Dim Address As New Specialist07.EcfAdresseringForm Address.Show End Sub [/Code] Where Specialist07 is a .NET DLL registered with regasm & gacutil and marked as COM exposed. EcfAdresseringForm is a .NET form. The resulting tlb file is linked to the dotm file by extra->References in the VBA Editor. It should check other properties for a patient in a db (like name and disease and stuff) do some transformations with it (insert predefined text from other table (based on patient ID, actually disease and some other variables but that is linked to the ID) & replace special characters in the text with those variables of this selected patient) and finally it should add this piece of text (with the inserted variables) into the word document. Later the document is saved in another table in the DB. btw the patient ID can change anytime by another application (This is handled in the .NET assembly, but the VBA can't update (since it doesn't share the same patient Manager object)) ~ DP
  11. From this website Access Specifiers Public: Gives variable public access which means that there is no restriction on their accessibility Private: Gives variable private access which means that they are accessible only within their declaration content Protected: Protected access gives a variable accessibility within their own class or a class derived from that class Friend: Gives variable friend access which means that they are accessible within the program that contains their declaration Protected Friend: Gives a variable both protected and friend access Static: Makes a variable static which means that the variable will hold the value even the procedure in which they are declared ends Shared: Declares a variable that can be shared across many instances and which is not associated with a specific instance of a class or structure ReadOnly: Makes a variable only to be read and cannot be written
  12. Hey there, Some serious problem occurred the other day. I'm building a reporting module. At the moment I have a .NET Application which consists of several buttons to the right side of the form. on the mid - left side there is Word 2007 hosted in a panel. The .NET Application loads a .NET DLL for some functionality for those buttons. Word loads a specific template which strips most of the ribbon and adds our own buttons and controls. (With VBA Scripts). These buttons calls the same .NET DLL as the application. Now I need to have access to a patient Identifier (for now perhaps more fields later on) which resides in the .NET DLL. I made a simple class EccPatientManager which holds the patient ID. Public Class EccPatientManager ' Shared ID private shared _id As Long = -1 ''' <summary> ''' Switch to patient ''' </summary> ''' <param name="value"></param> ''' <remarks></remarks> Public Shared Sub setPatient(ByVal value As Long) _id = value End Sub ''' <summary> ''' Retrieve patient ID ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public ReadOnly Property ID() As Long Get Return _id End Get End Property If I fill this in the .NET Application with valid data and call this from word (with vba ) I always get back -1. Probably because the .NET DLL is loaded twice, once for each process. Now I looked a little into IPC but with DDE I think this is a no-go with my current knowledge about it and the time constraint on the project. Also .NET solutions as .NET Remoting don't apply in my opinion as WinWord is not a .NET application, and I can't modify it's source Does someone can put me in the right direction to send data (as simple as integer value-types) from my application to the VBA script? I need to execute some code in VBA [create a form (from the .NET DLL) and show it, as well as supply the patient Identifier]. (No option to move the calling code to the .NET DLL as the VBA handles the GUI of the template for WinWord). Thanks for reading, let me know if you've got any suggestions.. ~ DP
  13. Hey there for single arrays you can use this: Default Public ReadOnly Property Item(ByVal index As Integer) As Object Get Return List(index) End Get End Property If you want to use an array of more items you can go for an implementation with 'rows' in your array. Create a class or structure which contains a single row of 8 items. then you can modify it to something like this: Default Public Property Item(ByVal index As Integer) As ArrayRow8 Get dim r as new ArrayRow8(.. input data from array8x8(index) .. ) Return r End Get Set(byval value as ArrayRow8) array8x8(index) = value ' You have to specify an operator overload or copy this per value. Return r End Get End Property however I must confess I don't know if it's a Microsoft Best Practice, but that's how I solved it in the past. Hope it helps. ~DP
  14. Also see this post ' Import ' Post message to handle <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Private Shared Function PostMessage( _ ByVal hWnd As IntPtr, _ ByVal Msg As UInteger, _ ByVal wParam As IntPtr, _ ByVal lParam As IntPtr) As Boolean End Function <DllImport("user32.dll")> _ Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, _ ByVal wParam As IntPtr, ByVal lParam As StringBuilder) As IntPtr End Function ' Message registration .. both app's CONSTANTS.MSG_STRINGWISSEL = RegisterWindowMessage("StringWissel") sending app SendMessage(hWnd, CInt(CONSTANTS.MSG_STRINGWISSEL), Nothing, New StringBuilder("TEST PATIENT")) Receiving app Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) ' Select appropriate message Select Case m.Msg ' Case we want to switch patients Case CInt(CONSTANTS.MSG_PATIENTWISSEL) Try 'Activate this screen Me.Activate() Dim ptr As IntPtr = m.WParam Dim patNr As Integer = ptr.ToInt32 ' Change patient ChangePatient(patNr) Catch ex As Exception ' In case of errors list them to the user MsgBox(ex.Message) End Try ' Case we want to send text Case CInt(CONSTANTS.MSG_STRINGWISSEL) ' Add received data to string object ' _BS.BuildString(m.LParam) Dim b As StringBuilder b = CType(m.GetLParam(GetType(StringBuilder)), StringBuilder) Me.Text += " : " + b.ToString() 'Me.Text += " : " + m.LParam.ToString() Case Else MyBase.WndProc(m) End Select End Sub Although I feel the Alloc could work as well, Allocation forces us to an exception for receiving string data. As well as strings could be send to (third party) applications which (might) not do anything with the string, thus leaving it into memory.
  15. Hey there For the several applications rolled out right now we want a single module to handle inter-application communication. i.e. we have one application (called App1 for simplicity) and with a button in this application we switch to another application (called App2). we want to exchange information such as patient number etc. My guess was to use Postmessage / sendmessage for this. All works fine, until we got to the point in which we have to communicate strings instead of numbers. An integer was easy to convert to a Intptr with new IntPtr(intValue) however creating an intptr from a string and send this pointer won't work. We also saw there was an overloaded sendmessage with a stringbuilder, but the receiving application receives other characters then those which were sent. As a third we tried to dissassemble the string and send it as bytes. as in this solution. While this solution works my co-workers ain't happy with such a kind of a work-a-round. if we can't send the string this project will come to an end, and we are bound to use an even more cumbersome solution, namely something with an invisible button, which we can change its caption with a call to SetWindowText. Thereafter on a text change we can read the string and dependent on some codes we can trace back what kind of 'message' is posted. I'm definitely convinced we shouldn't go for this, but if we can't find a way to send strings with a postmessage or sendmessage, I have no other option then to give in. :p Does someone know if it can be achieved in .NET? WM_SETTEXT is capable of sending strings, so somehow it should be possible in my opinion. Also in native code (where I program in @home) this ain't a problem, and is definitely possible. Someone any suggestions or tips? Maybe it's just me who's stubborn, I just want to know what's best to do, and if possible know how to send strings using messages. thanks in advance ~DP
×
×
  • Create New...