|
As long as you have database connections in the pool and you close/dispose of the connections, and you use the same connection string to connect to the database, then option 1 is going to be the better solution. Option 2 means that you have to leave a connection open - which is bad news if the server wants to recycle the database process, or the connection disappears for some reason and you attempt to do a database operation with a connection that is no longer valid.
Never design a system that keeps a resource open any longer than it necessarily has to - it just doesn't scale well.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
can anyone help me out about inheritance?
i have a base class inherited from a usercontrol. This base class contains a imagelist with 12 bitmaps and a datagrid, build in designtime.
Now i created 10 new classes inherited from my base class and weird as it is. the image list is copied and not inherited. changing the bitmaps in the base class doesn't change the ones in the other 10 inherited classes..
result is that i have to modify it for each of the classes. Another bad thing is that each class hass his own resource file containing the bitmaps. so 75kb x 10 = 750kb. i suppose this is no inheritance like i known it in Delphi, this is copying source.
Is there a way prevent copying the bitmaps but actually inheriting?
thx
Kurt
|
|
|
|
|
topcatalpha wrote: Is there a way prevent copying the bitmaps but actually inheriting?
Sounds to me like the bitmaps are not static, so a copy is created for every class instance. This would occur if they were 10 different derived classes, or not. Make them static.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Okay, Thx. i'm Gonna try that..
greetz
|
|
|
|
|
Wel,
i had the know it in advance, but i guess it's not possible to set a designtime created control as static.
So this seems to be a huge bug or missing functionality in C#.
Protected is not good enough, private is no option and static is not possible.
Even if you set it back to private in the parent form, the other derived forms still have the imagelist and you cannot delete them anymore...
So again this isn't inheritance, this is copying code.
But thx for you're time anyway.
greetz
Kurt
|
|
|
|
|
I'd Love to Have a ScrollBar which I can paint on my own. The Two Arrows for Up/Down and the actual Bar. I found a link on skinning Scrollbar on codeproject.com but it sort of was very lengthy. So is their an easier way to paint Scrollbars just as we paint other Controls???
Thanks...
|
|
|
|
|
I have a custom class having two members (a String object and a RegistryKey object). I have declared the class as Serializable and implemented the Iserializable interface. When I run the code ... an exception is thrown at the line where I try to serialize the RegistryKey object. My understanding is that this object also has to be serialized. But this cannot be done as RegistryKey class is sealed. Is there any procedure to serialize .NET class library objects?
I have to write my custom object to a file. My object contains other class library objects. Is there any alternative? Any help or suggestions are appreciated.
Varun Rokkam
|
|
|
|
|
Maybe you can exclude it from serialization and write a class that converts it to a string or other serializable object.
greetz
Kurt
|
|
|
|
|
Can any one tell me how to program the control "ExchangeTreeViewControl"?
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
hey , i am trying to figure , how can i add an onClick Event to
DataGridViewButtonColumn.
1.as for now i gata a datagridview which one of its columns is a DataGridViewButtonColumn , and i want to make an event so when the user click on any of the buttons in the column that event will fire.
2. another funny thing i cant find where i can change the default color of the button it seems no mater what i do to change it using the class properties it doesnt change.
thanks for helping , i didnt find any articles about that ,
peace
Net
|
|
|
|
|
|
How would i add a bitmap for my mian windows app to load up??? in this program:
#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
Michael
(Up and coming Game programmer)
EST
|
|
|
|
|
How do i link bitmaps to load with my game app window??Like if i'm using Dev-C++ Windows App Templete and want to link a bitmap with it in C. ( btw everything i'm talking about is C not C++)
Here the app program :
#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "NinjaWars";
PAINTSTRUCT paintStruct;
/* Device Context*/
HDC hDC;
/* Text for display*/
char string[] = "Hello, World!";
/* Switch message, condition that is met will execute*/
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Ninja Wars", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
Michael
(Up and coming Game programmer)
EST
|
|
|
|
|
MMaines2005 wrote: (Up and coming Game programmer)
Not very far, apparently
1 - try using meaningful ( or at least different ) subjects for different questions
2 - You're not likely to find much help here, given that you want help coding in C and on an unusual compiler, but especially not in the C# forum. The visual c++ forum is your best bet.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi its muneeb,
i am using File.Move(sourceFilename, destFilename)method in my windows service, where "sourceFilename" is path of file placed on another IP Address i.e: 12.15.200.114, and my system IP Address is 12.15.194.251, i am getting an exception while calling this method "can't find the file'\\12.15.200.114\Files\abc.pdf'", even it exists !!!!.
I also made a mapdrive (Z:\) for the other system in my system, and made path z:\\Files\\abc.pdf, but Again its not working
To check this out i made a console application for both scenarios and made the same process it is working good, but not working in my windows service.
Their may be an issue for system rights and service logon, but i checked my service with my user account, administrator account and local system account.
Plz help me out, bc its getting to late....
Muneeb
|
|
|
|
|
i make a software help to connect many device with PC,use COM1 in PC.it sent a syntax(have adrees of receiver),and after a little time the device(receiver) sent data to PC in COM1
my problem is if it ask all device,and wait the answer all device,it used many time.that is bad
I want it work multitasking-it ask a device,and when it wait for answer,it can ask other device...
note:COM1 only can sent or receive at the moment
leo
|
|
|
|
|
nta_3886 wrote: help me quickly
Not only is that not a useful subject, it is rude.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Aw crap, I hit the Spam button when I tried to hit the 5, sorry.
|
|
|
|
|
LOL !!
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
lolo lol........
|
|
|
|
|
Here is a XAML snippet (which would run in XAML Pad as well):
<TabControl>
<TabItem Header="One">
<TabControl>
<TabItem Header="OK">
<Button Content="OK"/>
</TabItem>
<TabItem Header="Not OK">
<Button Content="Not OK"/>
</TabItem>
</TabControl>
</TabItem>
<TabItem Header="Two">
<TabControl>
<TabControl.Template>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid KeyboardNavigation.TabNavigation="Local" SnapsToDevicePixels="true" ClipToBounds="true">
<Grid.RowDefinitions>
<RowDefinition Name="RowDefinition0" Height="Auto" />
<RowDefinition Name="RowDefinition1" Height="*" />
</Grid.RowDefinitions>
<DockPanel>
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" Name="HeaderPanel" ZIndex="1" KeyboardNavigation.TabIndex="1" IsItemsHost="true" />
<Label Content="Something" />
</DockPanel>
<ContentPresenter Name="PART_SelectedContentHost" Grid.Column="0" Grid.Row="1" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" ContentSource="SelectedContent" />
</Grid>
</ControlTemplate>
</TabControl.Template>
<TabItem Header="Apple">
<Button Content="One Apple a day, keep the doctors away"/>
</TabItem>
<TabItem Header="Carrot">
<Button Content="One carrot a day, ho well, nothing special"/>
</TabItem>
</TabControl>
</TabItem>
</TabControl>
Where every time you select the TabItem "Two" (in the toplevel tab) the inner TabControl would change its selected item.
(every second time it will be "Apple" every other second time it will be "Carrot")
Why does the inner tab changes?
How to work around this bug?
|
|
|
|
|
Please help me, I need to translate the following c# code to VC++ and I don't have too much experience in C#, and don't have time to get the experience. Please help!!.
using Copy_Vendor.API;
namespace Copy_Vendor_Client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
CopyVendor copyvendor = new CopyVendor();
copyvendor.SendPrintJobInformation(Convert.ToInt32(txtData.Text), 25.93);
}
catch (Exception ex)
{
string temp = ex.Message;
}
}
}
}
|
|
|
|
|
Wrong way, you should always go to C#.
|
|
|
|
|
AntonioRamirezL wrote: using Copy_Vendor.API;
There is #include in C++, but it does something slightly different. Do you have this component in C++ ? If not, you are hosed. You can write a C++/CLI wrapper for this code, but then you need .NET again.
AntonioRamirezL wrote: public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
None of this converts directly, you'll need to create an MFC form to replace this one
AntonioRamirezL wrote: CopyVendor copyvendor = new CopyVendor();
copyvendor.SendPrintJobInformation(Convert.ToInt32(txtData.Text), 25.93);
All this code does, is call the component. Do you have a non .NET version of the component ? If so, it's trivial, if not, you need to use .NET.
AntonioRamirezL wrote: catch (Exception ex)
{
string temp = ex.Message;
}
C++ has exceptions, but not exception objects.
At the end of the day, this is boilerplate forms code, which calls a black box. Either you have that black box visible to C++, or you don't.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you for your answer it was very helpful. Now I understand that I can convert almost all the code but this line is the difficult one
using Copy_Vendor.API;
I already have a Copy_Vendor.API.dll I'm not sure but I think it was written in c# no header file is provided (.h)and I thought I should use import. Don't you have any idea on how to convert this line to VC++?
Regards
Antonio
|
|
|
|
|