|
In the connection string, try replacing Integrated Security=True with Uid=[user];Pwd=[password]
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi
This is not a problem, I'm just trying to make myself clear how ListView works in virtualmode
So, I have ListView1 in virtualmode.
My ListView1 gets virtualitems from array, "baseArray() as ListViewItem":
Private Sub ListView1_RetrieveVirtualItem(..)
Dim x As Integer
x = e.ItemIndex
e.Item = baseArray(x)
End Sub
This works fine and is really fast.
The thing that I don't understand:
Changing the text of displayed ListViewItem or it's subitem affects also the corresponding item in baseArray.
This:
ListView1.Items(iSomeIndex).SubItems(0).Text = "sNewText"
Changes also the corresponding item in baseArray. Why this happens?
It seems that:
ListView1.Items(iSomeIndex)
is actually (I mean physically, sorry for the expression)
baseArray(iSomeIndex)
I earlier thought, that virtualmode copies shown items from baseArray.
But it seems that virtualmode does not work quite that way.
Could some of you explain what happens when virtualmode gets items from baseArray.
Thanks.
|
|
|
|
|
A ListView shows objects, whether it is used in virtual mode or not.
If you set the item at index X to be baseArray(X), then you simply copy the object reference from inside your baseArray array towards the items array inside the ListView, so whatever you do to your ListView item is changing your object in the baseArray, as they are one and the same object.
BTW: it does not make sense to have an array that "shadows" your items in a ListView, when you decided you want virtual mode; virtual mode is meant to overcome memory or speed limitations, that would arise when you would put a huge number of objects on a ListView, which in non-virtual mode would mean they have to reside in memory. So with virtual mode, you could create kind of a caching scheme, where only the currently visible objects need to be in memory.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Thanks
First part of Your answer was clarifying.
But this is not clear yet:
"it does not make sense to have an array that "shadows" your items in a ListView
Do you mean that it's not clever to use an array of ListViewItems, because the array itself consumes memory or speed? But how could it be done then? Data needs to be provided somehow for the ListView.
Data shown in ListView is stored in Database. During startup data is collected into this baseArray. Do you mean that data could be taken from the database into cache in runtime?
jtpaa
|
|
|
|
|
jtpaa wrote: During startup data is collected into this baseArray
That means all data is in memory, and virtual mode will not bring anything.
jtpaa wrote: Do you mean that data could be taken from the database into cache in runtime?
Yes. A very simple implementation would be to have RetrieveVirtualItem to go out and fetch one item from the database and feed it to the ListView. That way, you would not be holding any data in memory yourself, and the ListView would hold whatever it needs, and no more.
I am not saying this is the best approach, as it would cause a lot of small Database operations. There typically is an optimum somewhere in between; if you are willing to spend the effort, you could:
- create a cache, keeping a limited number of items, using WeakReference to make them garbage collectable;
- inside RetrieveVirtualItem, first look for the item in the cache; if found, pass it on. If not, read a number of items from the database, add them to the cache, and pass on the wanted one.
That is why it is called virtual: the ListView will act as if it has all data, but in reality it only has part of the data at any one point in time, sufficient to show the visible parts.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Ok
But could we say that my virtualmode version was atleast 5% virtual
Yes, the first thing that comes into my mind is that DB operation can be a bit slow because Database can also locate in local network. But this could be solved by taking several items with one search into cache.
Second thing is sorting. There are two columns (alphanumeric strings) in my ListView and user must be able to sort both columns. Also in sorting itself there has been difficulties. I haven't find a way to sort mixed strings properly with sql query.
jtpaa
|
|
|
|
|
when a list is virtual, it can't sort as it does not hold all the data; sorting means either the list is not virtual, or you do the sorting, the list does the displaying.
You can do sorting by including that in the SQL statement; see the ORDER BY clause.
If you can and are willing to keep the data all in memory (and suffer a potential startup delay), there is no need for virtual mode. If not, you need to add something clever; using virtual mode would be a part of that; caching could also be; keeping one or two entire columns (for sorting) is also conceivable.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
We have a working program in VB6 that gets the Windows Registered users and organization from the registry. It works fine on XP, Vista, etc.
If fails on Windows 7 and I believe W2008.
It returns Microsoft (which is incorrect) for both.
When we tried it with VB.net 2008 using
my.computer.registry.localmachine etc
It also fails but the same way. Obj below contains the string Microsoft. The line under (s =) also has Microsoft.
Can get the names but not the values????
Why
Here is the code.
Dim i As Short = 0
Dim s As String = vbNullString
Dim VNAR() As Object, SKNamesAR() As Object, Obj As Object
Const RO As String = "RegisteredOwner", ROrg As String = "RegisteredOrganization"
Const CV As String = "Software\Microsoft\Windows NT\CurrentVersion\" ' & RO
Const CVRO As String = CV & RO, CVROrg As String = CV & ROrg
Dim RK As Microsoft.Win32.RegistryKey = _
My.Computer.Registry.LocalMachine.OpenSubKey(CV)
Dim RK2 As Microsoft.Win32.RegistryKey
VNAR = RK.GetValueNames()
SKNamesAR = RK.GetSubKeyNames()
RK2 = RK.OpenSubKey(RO)
i = i
Obj = RK.GetValue(RO)
i = i
s = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion", "RegisteredOrganization", vbNullString)
|
|
|
|
|
That's the same place to get it in Windows 7. If this code is running under a 64-bit version of Windows 7, it won't work since VB6 cannot see the 64-bit registry, which is where this registration info would be stored. It should work fine under 32-bit Windows 7.
|
|
|
|
|
Thanks
Our products use the QuickBooks SDK which require running in x86 mode.
So what you are saying is that none of our products (VB6 or .Net) will be able to access the registry????
I believe that we can get other registry entries from VB6 wnd x86 versions of VB.NET. These would be entries that we create ourselves from the program.
So is there any way for this to work????
|
|
|
|
|
On x64 Windows, the Registered owner information is only written to the 64-bit side of the registry. You cannot get to it from a 32-bit application, like your VB6 code, or VB.NET code compiled as x86 only.
What your app is actually seeing (because you're running 32-bit code on a 64-bit OS) is stored under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion.
There are two ways to allow your app to get at the 64-bit registry. The first option is you'd have to use the Win32 Registry functions directly. You cannot use the built in Registry classes in VB6 or the .NET Framework to do this. Read more about the functions you have to use here[^].
The second option is to do it through WMI. YOu can read more about that here[^].
In eitehr case, you'r calling the Win32 functions directly, unable to use an built-in classes to make this easier for you.
|
|
|
|
|
Thanks Dave but this is a problem.
Our programs HAVE to run 32 bit mode for the other SDKs that we are using otherwise the main function will not work.
I am not clear on exactly what 'Win32 functions directly' means.
Do you mean something like this (taken from VB6)?
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
(ByVal lngRootKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
lpType As Long, lpData As Any, lpcbData As Long) As Long
RegQueryValueEx(lngKeyHandle, strRegSubKey, 0&,lngDataType, ByVal 0&, lngBufferSize)
You would think that the built in cases would handle it no matter what OS you are on. This is why many applications don't run on 64 bit OSes.
|
|
|
|
|
QBTeKcom wrote: Do you mean something like this (taken from VB6)?
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
(ByVal lngRootKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
lpType As Long, lpData As Any, lpcbData As Long) As Long
RegQueryValueEx(lngKeyHandle, strRegSubKey, 0&,lngDataType, ByVal 0&, lngBufferSize)
Yep. But, don't use VB6 versions of these Declares. The Long type in VB6 is not the same as the Long type in VB.NET.
QBTeKcom wrote: You would think that the built in cases would handle it no matter what OS you are on. This is why many applications don't run on 64 bit OSes.
The problem is that your 32-bit app shouldn't be using the 64-bit registry at all. After all, how are you going to use a 64-bit value in a 32-bit app? You can't...
QBTeKcom wrote: This is why many applications don't run on 64 bit OSes.
Not true. The reason they don't work is because they're not written properly in the first place. Most applications, historically, have been written assuming that all users are administrators on their machines. With Vista and 7, this simply isn't the case anymore, and for good reason. 64-bit has nothing to do with the problem.
|
|
|
|
|
Hi everybody,
to get out of a coding maze I'm stuck in, some input would be very welcome. In my application I set up a plugin framework using an IPlugin interface. What I want to achieve is that each plugin can react to (some) events of another plugin. Since I'm not so secure about the whole issue yet, I got lost... and stuck for hours now.
Does anyone have a good idea which would be the right way to pass events from one plugin to the other?
Thanks for some advice
Michael
|
|
|
|
|
You can't do it directly, that I can see anyway...
I think you'd have to come up with a way register those events with the plugin manager and any other .DLL's would have to subscribe to those events by getting a reference to them from the plugin manager.
But, this also exposes an order-of-load issue. What if a potential subscriber .DLL is loaded before the .DLL that is exposing the events?? You'd need som mechanism to tell each plugin that a new set of events is now available and they would get to subscribe to those events. I think your IPlugin interface just got a bit more complicated, or, at the very least, you just added a couple more interfaces to your plugin architecture.
No, I don't have anny examples since I've never done any kind of event generation in plugins. I'm only spewing from a thought experiment.
|
|
|
|
|
Hi Dave,
I am trying around with what you write: a way to register the events in the interface, so that other plugins can subscribe to selected events... I'm just tapping in the dark with which code line has to go into which class etc. (more details I wrote in the other answer, if you'd like to consider). Regarding the order-of-load issue I thought it might be possible to have a plugin subscribe to the anonymous standard (defined in the interface) and receive what comes... just like you connect a hose to a pipe and find out if it's beer or oil later
Thank you for having a look, anyway!
|
|
|
|
|
if plug-in B needs plug-in A, then they should not be handled at the same level, since you could end up having B and not having A around.
if all plug-ins are at the same level of hierarchy, I would look for what they have in common. Maybe you should broadcast plug-in arrivals and removals, and possibly pass their capabilities around.
Example: your framework could have a mechanism to detect image producers; when an imageProducer plug-in gets added or removed, you could signal that to all plug-ins present (by calling a method to that effect, part of your plug-in interface); or to all the ones that are imageConsumer, or to all the ones that subscribed to your framework's "reportImageProducersChanged" event.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hi Luc,
by now I'd still say that if B would need A then I'd treat them in the same plug-in. And if it was only to reduce chances of avoidable confusion So let's say they are on the same level of hierarchy and have something in common.
You write it in a way that makes me think it's an easy thing: "... possibly pass their capabilities around." or "signal that to all plug-ins present". How I would do that is exactly what I'm looking for - codewise. My confusion is at the point where I don't know which statement or method has to be in which class...
What I have: An interface IPlugin which has no methods yet, but defines the event "PlugInEvent" which I use for the purpose of testing (i.e. understanding). Each plugin has a PluginHandler Class which implements IPlugin, as well as the main MDI form. But the only way how I can consume plugin events from outside a plugin by now is to use Addhandler pluginMainform.event - but hardcoded stuff doesn't make a lot of sense considering the fact that a plugin is supposed to be more or less anonymous and flexible.
Your example hits the point: I'd be happy if I could make a plugin that signals "Free Beer for everyone" (e.g. when a certain button gets clicked) be noticed from any other plugins which would be interested in that . From between your lines in the example I guess a method in the IPlugin interface itself has to signal, right? But how does the interface itself receive a plugins event in the first place? Would I use addhandler inside the interface?
|
|
|
|
|
OK, here is the beginning of a concept, consider it pseudo-code (it will resemble C#); you didn't tell hardly anything of the kind of communication you want, so it may be rather abstract and besides the things you are looking for.
1.
the framework detects plugins and organizes plugin addition/removal.
It holds a list of plugins.
You can organize that in many ways.
2.
If you really want all plugins to be aware of each others presence, you could do this:
The framework signals those insertion/removal changes to all plugins.
public class PluginsCollectionsChangedEventArgs : EventArgs {
public IPlugin plugin;
public bool Removed;
}
interface IPlugin {
PluginsCollectionChanged(object sender, PluginsCollectionsChangedEventArgs e);
}
But I would not recommend this. I'd rather go for communication at a more functional level.
3.
if you have some objects with a producer-consumer situation, you could create a singleton class, that organizes the transportation. It could hold a list of producers and consumers, and a queue of goods. Each plugin could subscribe as producer and/or as consumer. The class could hold a queue of goods, with limited or unlimited capacity. It could signal consumers when goods become available; it could signal producers when space becomes available to store more goods produced.
4.
If the type of goods is not known beforehand, you could implement 3. as a base class and have the plugins create specialized transportation; and you could consider a generic implementation.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hello Friends,
I need to send an User Defined Type to a C++ DLL, but I am receiving "Bad DLL Calling Convention" error.
This "WORKS" (Without UDT):
In C++:
extern "C" __declspec(dllexport) int TestFx()
{
return 1;
}
---------------------------------------------------------
In VB:
Private Declare Function TestFx Lib "E:\DLL\DevCPP\CPPSource\Output\MingW\ProjectDlltest.dll" () As Long
But when I try with some UDT, it "FAILS":
In C++:
struct Vector
{
float x;
float y;
};
extern "C" __declspec(dllexport) int TestUDT(Vector *V)
{
return 1;
}
---------------------------------------------------------
In VB:
Private Type Vector
X As Single
Y as Single
End Type
Private Declare Function TestUDT Lib "E:\DLL\DevCPP\CPPSource\Output\MingW\ProjectDlltest.dll" (ByRef V as Vector) As Long
Dim Vec(1) As Vector
Dim RetVal as Long
RetVal = TestUDT(Vec(0))
MsgBox RetVal
Why the first program without UDT works and the second one not ?
I am using Dev-C++ for building the DLL.
Please Reply,
Thanks in advance.
|
|
|
|
|
Hi Friends,
I solved it out:
I Used __stdcall in combination with extern "C" __declspec(dllexport):
i.e., for e.g.
extern "C" __declspec(dllexport) __stdcall int FunctionName(Vector *V)
Thanks.
|
|
|
|
|
Hello,
Is Visual Studio 2010 (Visual Basic 2010) compatible with for example SQL 2005 ?
I have tried to convert a small application from VB 2008 to VB 2010 this application uses SQL 2005 and wont work directly.
I have installed a SQL 2008 and imported the database. The same application is running in VB 2010 with SQL 2008 without any problem.
IS this a setting or Service pack that need to be dont to acces SQL 2005 from VB 2010.
thanks
DCA
|
|
|
|
|
I think it should be compatible. Although can't find anything via google yet to say otherwise.
Is it giving you an error or what makes you think it is not working?
|
|
|
|
|
|
Hello,
I have the following question.
I have written a VB 2008 program for registering Rooms in a Hotel.
Using a Touch Screen for entering everythin so there is no keyboard and mouse installed on the PC.
So i have a buttom for every room on a main screen. When pressing for example room 2 , there is a new form that opens on top of the main form.
in the main programm is have frmxxx.show(). In the frmxxx() i have set in the load : FrmMain.enabled = false
So it is not possible anymore to click on the main form , so i have blocked that the users can change the form back to the main.
Now the problem : sometimes , the user is clicking to fast i think (before the frmMain.enabled = false) and the main window is coming on top of the frmxxx. so the mainform is hiding the smaller frmxxx so the user has a big main form wich is at that time disabled. so the screens are on top.
The only way to solve this is with a keyboard CTRL-TAB but because of the missing keyboard (due to the touch screen) it is not possible.
I have already tried to set the main form enabled = false before opening the frmxxx. but this is not working when the mainform is still active.
I dont want to hide the main form , so i wnat it set to disabled.
Does anyone can give me advise on this maybe stupid question.
Thanks
Best regards
DCA
|
|
|
|
|