|
I want to highlight an item in the ListBox, i.e. make its font bold or make its color green, no matter. I read about the DrawItem event, but unfortunately this item happens only when some action with ListBox is performed, but I want to highlight an item on checking a checkbox that is not in the ListBox.
|
|
|
|
|
I figured it out, I just use the DrawItem event for manual painting of the control and invoke this event by using the Refresh() method of ListBox .
|
|
|
|
|
Hi
VC++ 2005 EE
I'm writing an app which is going to display some 3D figures on System::Windows::Forms::Panel^ panel
The problem:
I've written my own class which handles all OpenGL stuff. So all I have to do is:
Create new 3D figure object, and draw it with panel's Paint method.
Constructor needs panel's HWND, so i did something like this:
TFigure *Figure;
Figure = new TCuboid( (HWND)panel->Handle.ToPointer() , panel->Width, panel->Height, 3, 3, 7 );
But this solution doesn't work properly. When i'm trying to initialize OpenGl machine
with this code (inside TCuboid construcor):
m_gHDC = GetDC( hwnd );
SetupPixelFormat();<br />
m_hRC = wglCreateContext( m_gHDC );
the variable: m_hRC is NULL and it shouldn't be.
I've tried my class code with other IDE and all was fine. So i think the problem is with getting panel's HWND.
Can somebody help me please?
-- modified at 9:52 Sunday 14th October, 2007
|
|
|
|
|
I have built a windows form using C#( .NET 2.0 ). The form has a label with text set to “:My label text.” When I build and run the form here everything looks fine.
When a person is running the form in UK he sees the label text as “.My label text:”
I am not able to figure out the reason for the colon to be moved to the end and the fullstop to be moved to the front.
I don’t think the UK locale(langauage and region) would be causing this.
Any pointers?
Thanks,
Sudhir
|
|
|
|
|
sudhirkamath wrote: I don’t think the UK locale(langauage and region) would be causing this.
Most likely could be the cause...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
hello techs,
I have a small project which enables database backups.
I have to to do backup's for multiple database @ a time.
For that i need to use Threading concepts.
the below code is for database backup :
-----------------------------------------------------------------------------------------------------
public void backUpDatabase(string DBname, string setBakUpPath)
{
SqlCommand sCom = new SqlCommand("BACKUP DATABASE " + DBname + " TO DISK = '" + setBakUpPath + "' WITH NOFORMAT, NOINIT, NAME = 'Full Database1 Backup', SKIP, NOREWIND, NOUNLOAD,STATS = 10", sCon);
sCom.CommandType = CommandType.Text;
try
{
sCom.ExecuteNonQuery();
MessageBox.Show("Database " + DBname + " : BackUp Done!", DBname + " BackUp", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString(), "Backup ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
sCom.Dispose();
}
-----------------------------------------------------------------------------------------------------
all the databases will be loaded to a list box and i will select a database and clicks on button "Backup Database" and it will starts backup.... I need to do the backup in a thread. Now on the datagrid ... it will show the "db name", "Status : backup going on/backup done" and finally % of percentage of backup in the third colum of grid (u can avoid if this a bit time consuming... )
Please help me to solve it, if any clarifications needed... please ask ... thanks ...
A123-B321
|
|
|
|
|
I think db "backup time" depends on db size.
You can check your db backup thread status via standart c# event technick (read msdn for it)
|
|
|
|
|
Hi Guys and Gals.
I have a window form that has the autoscroll property set to true. This form needs the scroll bars. Now the problem is that I have a menu and a toolbar control. I want it to stay at the top even though I am scrolling to the bottom so that when someone is at the bottom of the screen they can still for instance click the save button without having to scroll all the way to the top.
Can someone please assist me to a solution?
Your help will be greatly appreciated.
Regards,
Elizma
|
|
|
|
|
Easy. Put your form's contents, except for the toolbars in a Panel control docked to the form and turn on it's autoscroll property.
|
|
|
|
|
Hi ,
I`ve implemented AppBars with help from the C# Does Shell-Part 3[^] article , but am having issues with the "Show Desktop" command .
What happens is that the AppBar itself gets minimized but upon restoration , its width becomes half of the earlier value. While debugging , i saw that the AppBar WndProc receives a FullScreenApp OS notification.
I`m handling this as :
if(lParam ==1 & appbar is topmost)
{ send it to bottom of z-order}
else if (lParam ==0 & appbar is bottom)
{ bring appbar to top of the z-order}
I need this logic so that my appbar is hidden when Word or IE enters full-screen mode & also to allow the user to see the start menu window.
Is there any other unique message that the OS sends to all active windows upon "Show Desktop" (other than WM_MINIMIZE) that i can handle ?
Any help or pointers are most appreciated.
Thanks in Advance
|
|
|
|
|
Hi,
I'm quite new to using VC++ and Windows forms. Although forms work well so far, I have an issue passing a handle from my main function to my form.
In main() I open a handle to a device. This handle must be available to my form so that when I click a button, it can use this handle to access my device and perform the intended action.
What is a good way to deal with this ?
regards
Marcel
recursive:
See "recursive"
|
|
|
|
|
I don't code C++, but as far as I know, the handle (or any other object) can only be accessed from inside the method they were defined in.
If you define the handle outside a method, it should be possible to access it everywhere.
Virtual1ty
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
OK, I defined it as a global now and it works well.
It basically gets written to only one at startup of the application and only read in the rest of the application so this global may be the easiest way to deal with it.
Thanks,
Marcel
recursive:
See "recursive"
|
|
|
|
|
You can also pass the handle as an argument to the form's constructor, or create a (at least) writable property which you can pass the handle to. Either one would be neater than having the handle defined as static (global) variable.
|
|
|
|
|
hi,
I m writting an windows forms based application in C# and am facing an unusual problem..I have thrown an exception from a my business logic code but the execution control gets lost after I raise a business exception!
(The business logic code is in a seperate library project)
has this happened with someone? please help..
|
|
|
|
|
I think you're going to need to be a little clearer in the explanation of what's happening before any one will be able to help you.
alesh_nitre wrote: ..I have thrown an exception from a my business logic code
Is this a custom exception or one of the standard .NET exceptions? How are you throwing it?
alesh_nitre wrote: the execution control gets lost after I raise a business exception
This doesn't make sense to me. What do you mean "the execution control gets lost"?
|
|
|
|
|
Thanks for such an urgent reply and sorry for a lousy explanation! But two days back i myself was unable to locate or reason about the cause of the problem. I'll explain better now. (Please ignore previous post)
About "the execution control gets lost" ->
I was debugging the code using VS2005 debugger pressing F10 and F11 along my way. But the moment the exception was thrown following things used to occur
1. The yellow arrow that shows current executing statement used to get lost
2. The call stack window used to go blank suddenly.
3. The application hung.
The app used to hang even in the release mode and so on.
-------------------------------------------------------------------
Neways. Now that i have better idea why this is happening I have summerised the code as follows. Please have a look at this -
private void button1_Click(object sender, EventArgs e)
{
// this code snippets reproduces the problem i stated
MySqlConnection con = new MySqlConnection("server=192.168.1.45;user id=root;Password=pqrs;database=dev");
//(I am using MySql .NET Connector 5.1.2)
con.Open();
try
{
// Select from any table that ***HAS BLOB DATA FIELD***
string selCmd = "SELECT * FROM document";
using (MySqlCommand allDocsCmd = new MySqlCommand(selCmd, con))
{
//Execute Reader
using (MySqlDataReader reader = allDocsCmd.ExecuteReader())
{
// ... some logic may be while(reader.read()) loop etc.
// Say this code throws an excpeption at some point..
throw new ApplicationException("Any exception ..");
// we expect the the execution control to go in the catch block below but
// it gets lost in the manner i told
}
}
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}
|
|
|
|
|
The code looks ok to me. Given the explanation, it sounds like you are actually hitting an exception in the MySqlDataReader code. When you get into that state, try pressing the "pause" button on the debug toolbar, which will break the execution and place you on the currently executing line of code. If it can't find the code, it should tell you and give you the option of looking at the assembly code. You could also try narrowing the try/catch by putting it inside the innermost using block directly around the code you think is throwing the exception.
Also, are you using .NET 2.0 or later? If not, you can try adding a blank catch block. It's possible (although unlikely) that the code is throwing an exception that isn't properly wrapped as a .NET exception. The empty catch block will catch that, but you won't have any exception data.
|
|
|
|
|
You are rite! the problem is indeed with MySqlDataReader..
btw I tried what you suggestd.. but pressing pause returned the control to the "throw new App.." statement with the arrow in green color.
To dig further suspected the 'using' blocks in my code made it hang. so I removed them to find that my doubt was right. I closed the reader manually rather than the 'using' doing it for me.. following is the code..
<br />
string selCmd = "SELECT * FROM document";<br />
MySqlCommand allDocsCmd = new MySqlCommand(selCmd, con);<br />
MySqlDataReader reader = allDocsCmd.ExecuteReader();<br />
reader.Close();
The execution hangs at reader.Close();
This for sure is now a MySqlDAtaReader related problem..I selected everything else but the blob field from the table and it worked fine i.e.
"select id,data from document" hangs but
"select id from document" works ok.
('data' is a LONGBLOB field in document table)
I am searching a cause and fix but lemme know if you have ne idea why this is happening..
Thanx.
|
|
|
|
|
Good to hear that you have tracked down the problem. I'm not familiar with the MySqlDataReader code so I probably won't be able to help you there. The pause button trick works most of the time, but as you found it doesn't work all of the time. It was worth having you try it, just in case.
If you have access to the source code for the MySqlDataReader, you should probably start there and look at what the Close method is actually doing. If not, you can try using Reflector[^] to look at the code.
My guess, since this works correctly as long as you exclude the blob field, is that the blob field is allocating another datatype internally which isn't being properly handled in the Close call.
|
|
|
|
|
I will work on the reader.Close() and put a small update here so that others get help if they bump in to this kinda problem..neway. the "press pause button" trick is helping when everything seems 'frozen'. The green arrow appears and pressing F10 shows this messsage
The CLR has been unable to transition from COM context 0x191288 to COM context 0x1913d8 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
|
|
|
|
|
alesh_nitre wrote: I will work on the reader.Close() and put a small update here so that others get help if they bump in to this kinda problem
That would be good.
The message you are getting is really nothing more than Visual Studio telling you that the application has frozen and isn't responding to messages. It's a 50/50 chance that the message is actually meaningful and the application is really frozen.
|
|
|
|
|
Hi
Iam using C#.Net 2.0 backend is MS Access....
When I want to update a record folowing exception has been appeared:
Concurrency violation: the UpdateCommand affected 0 of the expected 1 records
Can anyone help me about the cause of the exception?
regards
Somasundaram
|
|
|
|
|
To test concurrency the database access test whether any changes have happened since you loaded the data.
Have a look at the original data (assuming you are using DataSets) and the data in the database.
They differ and therefore the db access can not find the record it should update.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
hello,
Does anyone have the crack of the installshield 2008.
best regards.
dghdfghdfghdfghdgh
|
|
|
|