Sub CommentUncomment()
Dim StartPoint, EndPoint As EnvDTE.EditPoint
Dim Sel As EnvDTE.TextSelection
Sel = DTE.ActiveDocument.Selection()
StartPoint = Sel.TopPoint.CreateEditPoint()
EndPoint = Sel.BottomPoint.CreateEditPoint()
DTE.UndoContext.Open("Comment/Uncomment")
Try
Do While (True)
StartPoint.StartOfLine()
If StartPoint.GetText(3) = "//~" Then
StartPoint.Delete(3)
Else
StartPoint.Insert("//~")
End If
If (StartPoint.Line = EndPoint.Line) Then
Exit Do
End If
StartPoint.LineDown()
Loop
Finally
DTE.UndoContext.Close()
End Try
End Sub
I am developing an application which stores its configuration in an INI file in the same directory as the executable. So I need to get the executable directory and build the path for the INI file.
Some WIN32 syscalls are available for this job: GetModuleFileName, PathRemoveFileSpec and PathAppend. PathRemoveFileSpec and PathAppend are defined in shlwapi.h, which IS available in the SDK. So I expect the shlwapi.lib to be available, too, right? But it isn't, so a workaround is needed.
Here's the code needed to build the new path, based on the absolute path obtained from GetModuleFileName. Some error handling is provided, but error shouldn't really happen. GetModuleFileName returns an absolute path, so I'm sure that at least one '\' will be found.
#include <cstring>
#include <windows.h>
wchar_t Path[MAX_PATH];
if (0 == ::GetModuleFileName(NULL, Path, MAX_PATH)) {
//Error that shouldn't happen
::wcscpy(Path, L"IniFile.ini");
} else {
//Find the last '\' in the absolute path
wchar_t* pos = ::wcsrchr(Path, L'\\');
if (!pos) //Error, '\' not found
pos = Path;
else
pos++;
::wcscpy(pos, L"IniFile.ini");
}
Of course there's no such configuration item in that screen, so you have to do it by hand. Which is not a problem, by the way, only if they told me in the first place I'd be happier...
Locate the file
talk.iniof your user under trillian installation tree. Browse to the
Loggingsection, find the
Viewerelement and update it with the full path of your viewer. I use Scintilla Text Editor, so for my setup I have:
[Logging] Viewer Use Association=0 Viewer=D:\Programmi\SciTE\SciTE.exe
While developing a project I stumbled upon this; imagine you want to handle a WM_CONTEXTMENU message. You place a ON_WM_CONTEXTMENU() in the class message map, right? Then you'll get a
error C2065: 'ON_WM_CONTEXTMENU' : undeclared identifier
I found some references on the net: they say that the context menu message is either not supported or handled by buggy code. I can easily believe this, but what if I want a quick solution to handle the message?
The solution turned out to be extremely simple. The ON_WM_CONTEXTMENU macro is defined in afxmsg_.h, which surely gets included somewhere in your files, but somehow its definition is "lost" somewhere.
So you just copy the following code and paste it into the file with the message map:
#ifndef ON_WM_CONTEXTMENU
#define ON_WM_CONTEXTMENU() \
{ WM_CONTEXTMENU, 0, 0, 0, AfxSig_vWp, \
(AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(CWnd*, CPoint))&OnContextMenu },
#endif
This is exactly the same code in afxmsg_.h so I didn't invent anything. Neither did I connect the brain before adopting and posting this solution. It's just a stupid workaround for another stupid bug in eVC4 / ppc2003. And, quite strange, does work for me :-)
Here's a quick note on how to get it working without Samsung software. It requires pmplib and, optionally, a quick python hack I developed. My hack is tested under m$-windows and Debian GNU/Linux.
Get started by rebuilding or updating the device database (refer to pmplib website for more info). If you also asked pmplib to update/build playlists it will convert winamp-style playlists to be playable on your device, and you don't need anything else.
If you want to build playlists from scratch, in the format playable by the YH920 you need to download my playlist package. Sample command:
python test.py -b H:\ -o Tyr H:\System\MUSIC\Tyr-EricTheRedThis uses the device mapped to H: , creates a playlist Tyr.plp in the Playlists folder that will play all files in H:\System\MUSIC\Tyr-EricTheRed
Hope this is useful, as it was for me.
If explanations are not good (and they are not good, I know) feel free to send me a better version.
Disclaimer: I'm not a visual basic programmer. In fact I don't know visual basic at all; this was my second experiment in vb.
A previous post was about a similar macro for Visual Studio 6.0. This one works for the 7.1 IDE.
Tipographic note: to constrain this code in blog's page width, I've had to break long lines with '\'. I don't know if this line-break is acceptable to vb, so don't copy&paste blindly.
Sub CommentUncomment()
Dim StartLine, EndLine, Temp As Integer
Dim Sel As TextSelection
StartLine = ActiveDocument().Selection.TopLine
EndLine = ActiveDocument().Selection.BottomLine
If EndLine < StartLine Then
Temp = StartLine
StartLine = EndLine
EndLine = Temp
End If
For Temp = StartLine To EndLine
Sel = ActiveDocument().Selection()
Sel.GotoLine(Temp)
Sel.StartOfLine(\
vsStartOfLineOptions.vsStartOfLineOptionsFirstText\
)
Sel.CharRight(True, 3)
If Sel.Text = "//~" Then
Sel.Delete()
Else
Sel.Text() = "//~" & Sel.Text()
Sel.GotoLine(Temp)
Sel.StartOfLine(\
vsStartOfLineOptions.vsStartOfLineOptionsFirstText\
)
End If
Next
End Sub
Disclaimer: I'm not a visual basic programmer. In fact I don't know visual basic at all; this was my first experiment in vb.
Over the years I've been fighting with Microsoft Visual Studio 6 editor, and missing many of Scintilla's features; one of the most useful is the capability to comment/uncomment a line of code. So I wrote this little macro, and usually bind it to a Ctrl+Q; hope someone will find it useful!
Tipographic note: to constrain this code in blog's page width, I've had to break long lines with '\'. I don't know if this line-break is acceptable to vb, so don't copy&paste blindly.
Sub CommentUncomment()
'DESCRIPTION: Comment/Uncomment a line of C++ code.
'Begin Recording
StartLine = ActiveDocument.Selection.TopLine
EndLine = ActiveDocument.Selection.BottomLine
If EndLine < StartLine Then
Temp = StartLine
StartLine = EndLine
EndLine = Temp
End If
For i = StartLine To EndLine
ActiveDocument.Selection.GoToLine i
ActiveDocument.Selection.StartOfLine \
dsFirstText, dsMove
ActiveDocument.Selection.CharRight dsExtend, 3
if ActiveDocument.Selection.Text = "//~" Then
ActiveDocument.Selection.Delete
Else
ActiveDocument.Selection = "//~" + \
ActiveDocument.Selection
End If
Next
'End Recording
End Sub
error LNK2001: unresolved external symbol "public: __cdecl std::_Lockit::_Lockit(void)" (??0_Lockit@std@@QAA@XZ)Solution:
#ifndef _MT
#include <afxwin.h>
#include <yvals.h>
namespace std {
_Lockit::_Lockit() {}
inline _Lockit::~_Lockit() {}
}
#endif //_MT
<<<<
|
|
January '09 | |||||
| Mo | Tu | We | Th | Fr | Sa | Su |
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |
2006-2008 Giuseppe 'Cowo' Corbelli | Cowo's homepage | Cowo's photo page | Contact me | Back to top
Design by Andreas Viklund | Serendipity Template by Carl