Jump to content
  • Advertisement
Sign in to follow this  
ldramire

[.net] C# 2.0: Can't debug without rebuilding ... and a question on TabControls

This topic is 4419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey peeps, Ok, so I recently upgraded to VS 2005 and started working on a C# tool and have come across these two issues. 1 - If I clean the project and then hit F5 to debug, it gives me an error telling me that it can't find the .exe file. I would expect it to just rebuild the .exe and continue, as it did in 2003. Ok, so I build the project and debug. Then, if I make any changes to the source files and start debugging, the program won't reflect my changes. I have to explicitly build the project before running it. I would expect it to detect that the source has changed and rebuild as necessary, again as it did in 2003. A friend of mine started a C# project in VS 2005 recently as well and he does not seem to be having this problem, so maybe it's something I've screwed up? I tried making a whole new project and same deal. I can't find any project settings or optionst to fix this. Anyone know what gives and how to fix this little annoyance? 2 - Totally unrelated, but while I'm posting ... for my tool I'm using a TabControl onto which I add TabPages dynamically. Now I want to be able to also close the pages dynamically when a user middle-clicks the top of the TabPage (like in Firefox). Problem is I can't find any event that will let me do this. It seems that the tops of the TabPages (the actual "tab" parts) generate events for the TabControl, not the TabPage you clicked on (which seems odd to me), so there's no way (at least that I've found so far) to know which tab you actually clicked on. I'd like to be able to remove any tab, whether it's in the foreground or background. Any suggestions? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Haven't found anything on #1, but #2 can be done using:

VB.NET, but I'm sure you'll have no problems converting.

Private Sub TabControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabControl1.MouseDown

If e.Button = Windows.Forms.MouseButtons.Middle Then

TabControl1.TabPages.Remove(TabControl1.SelectedTab)

End If
End Sub

Share this post


Link to post
Share on other sites
That's actually the first thing I tried. Unfortunately, the selected tab will be the one in the foreground, so middle-clicking any tab in the background just removes the one in the foreground.

Thanks for trying though.

There has to be a way to do this ...

Share this post


Link to post
Share on other sites
There is a function in TabControl called GetTabRect(). Iterate through each tab page, and check for an intersection between the tab page's rectangle and the mouse position. The one that intersects is the the tab page you want.

Share this post


Link to post
Share on other sites
Good call. I didn't notice that the correct tab wasn't being removed. This works:



Private Sub TabControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabControl1.MouseDown

If e.Button = Windows.Forms.MouseButtons.Middle Then

Dim iLp As Integer

For iLp = 0 To TabControl1.TabPages.Count - 1


If TabControl1.GetTabRect(iLp).Contains(e.X, e.Y) Then

TabControl1.TabPages.RemoveAt(iLp)
Exit For

End If

Next

End If

End Sub

Share this post


Link to post
Share on other sites
Sweet, that worked, thanks guys.

Now if only someone could explain why the project won't auto-rebuild when debugging ...

Share this post


Link to post
Share on other sites
Sounds like a setting somewhere isn't set, but I've been unable to find such a setting. Doesn't happen in my projects.

Share this post


Link to post
Share on other sites
I'm using Visual C++ 2005 Express edition, but i think the setting should be similar (i was able to replicate the behaviour on VC++).
In the options dialog, select "Projects and Solutions" -> "Build And Run". Now, on the right side you will see the option "On Run, when projects are out of date:". Current value should be "Never build" (that's why you're getting the error). Now, if you don't want to be bothered with some dialogs you should set the value to "Always build".

Good luck!

Share this post


Link to post
Share on other sites
Didn't notice that setting until I check the Show All checkbox. [oh] I would imagine the default is Always build since I didn't even know it was there so couldn't have changed it. [grin] Strange that the OP's must not have been.

Share this post


Link to post
Share on other sites
Hey Paulius,
I checked that setting and it is indeed set to Always Build. I tried changing it and a few of the other options on that page for the hell of it , but still, same deal.

This also happens on different computers (so far I've tried at home and at my school lab) and the problem persists.

Interesting thing though: I have a couple of projects in my solution that I started in 2003 and ported over (I just opened them in 2005 and let it do the conversion) and they work fine. Only this one project (and any new ones I've created to test) that are created specifically in 2005 has this issue.

Weirdness.

[Edit:]

I tried making a brand spanking new Solution and moving my project over into it and it works as intended. Maybe my solution file got corrupt somehow ... or something ... I guess I'll just start with a fresh solution and move each project over independently.

Thanks for the help guys.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!