|
What exactly do you mean by "disable font formatting"? You can set the default by using SetDefaultCharFormat[^] and -i guess- you "disable" any other formatting by not doing any other formatting (like, not using SetSelectionCharFormat[^]).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
key combination like "ctrl+e", "ctrl+r" make the alignment in CRichEditCtrl!
perhaps there are other hotkeys that you can use to make editing!
How i can disable it?
i found some solution:
SendMessage(EM_SETTEXTMODE, TM_PLAINTEXT, 0);
if you have any information about this, please give me link
|
|
|
|
|
No info, just what MSDN would give you, hope it works as expected.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
I am trying to debug a program that is having a problem loading bitmaps. The program compiles fine, but it crashes whenever I open a bitmap file and try to manipulate it. This is a program I inherited from someone else and it is multi-threaded and fairly large. It has been difficult to track the problem (which seems to be a runtime error), but I have done so with the usual debugging methods (breakpoints, etc) and I am lost with what to look for in the code for the problem. The program was originally built on a much older framework and this has been part of a transition from windows xp to windows 7. However, this transition has not been so easy...and I am not a professional programmer and have been learning as I encounter problems. The program always seems to crash right at this line.
CWinSTMDoc *pDoc = CreateNewDoc(GetDocument());
I step into it and get lost in a world of windows messages...
Here is the output window around where the program crashes:
WinSTM.exe': Loaded 'C:\Windows\System32\wpdshext.dll', Symbols loaded (source information stripped).
'WinSTM.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7600.16385_none_72fc7cbf861225ca\GdiPlus.dll', Symbols loaded (source information stripped).
WinSTM.exe has triggered a breakpoint
First-chance exception at 0x75c99617 (KernelBase.dll) in WinSTM.exe: Microsoft C++ exception: CInvalidArgException at memory location 0x001af0a4..
Warning: Uncaught exception in WindowProc (returning 1).
'WinSTM.exe': Unloaded 'C:\Windows\System32\wpdshext.dll'
'WinSTM.exe': Unloaded 'C:\Windows\winsxs\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7600.16385_none_72fc7cbf861225ca\GdiPlus.dll'
'WinSTM.exe': Unloaded 'C:\Windows\System32\ExplorerFrame.dll'
'WinSTM.exe': Unloaded 'C:\Program Files\Common Files\microsoft shared\ink\tiptsf.dll'
The thread 'Win32 Thread' (0x884) has exited with code 0 (0x0).
Here is the code immediately before the program aborts and the debugger yells at me:
void CDocument::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU)
{
TCHAR szFullPath[_MAX_PATH];
ENSURE(lpszPathName);
if ( lstrlen(lpszPathName) >= _MAX_PATH )
{
ASSERT(FALSE);
AfxThrowFileException(CFileException::badPath);
}
if( AfxFullPath(szFullPath, lpszPathName) == FALSE )
{
ASSERT(FALSE);
AfxThrowFileException(CFileException::badPath);
}
m_strPathName = szFullPath;
ASSERT(!m_strPathName.IsEmpty());
m_bEmbedded = FALSE;
ASSERT_VALID(this);
TCHAR szTitle[_MAX_FNAME];
if (AfxGetFileTitle(szFullPath, szTitle, _MAX_FNAME) == 0)
SetTitle(szTitle);
if (bAddToMRU)
AfxGetApp()->AddToRecentFileList(m_strPathName);
ASSERT_VALID(this);
}
My gut is telling me that I have a pointer that is not returning the correct value, but I am having trouble tracking it down. Thanks for any and all help!
Best,
Andrew
|
|
|
|
|
Well, the first thing that's needed is to identify the exact error that's causing the crash.
When it crashes, look in the "Output" window, and find the exact error message wording, and show it here.
The Output window should be in the lower part of the Visual Studio main window, below where it shows the code.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Found the output window, I hope the additional information helps.
|
|
|
|
|
My hunch from the code you show, is that the error might be happening inside the "CreateNewDoc" function.
The next thing I would do is place a breakpoint at that line you said where it always crashes.
Run the program until it breaks at the breakpoint, and then single-step through the code until the error is raised. To single-step, press F11 once to enter the "CreateNewDoc" function, then F10 to execute each line of code.
Then, when the error is raised, take note of the exact line of code that you executed to cause the error, and, (very important) what function that line of code belongs to.
Now show some of the code where the error occurs.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I tried to get as close as I can to where the debugger throws an error at me.
|
|
|
|
|
I am trying to get the list of windows displayed in the windows taskbar and am doing so in the following manner:
HWND hDesktop = GetDesktopWindow();
HWND hTray = FindWindow(_T("Shell_TrayWnd"), NULL );
HWND hReBar = FindWindowEx( hTray, NULL, _T("ReBarWindow32") , NULL );
HWND hTask = FindWindowEx( hReBar, NULL, _T("MSTaskSwWClass") , NULL );
HWND hToolbar = FindWindowEx(hTask,NULL,_T("ToolbarWindow32") , _T("Running Applications") );
long cnt = SendMessage(hToolbar, TB_BUTTONCOUNT,0,0);
long pid,hprocess,text,len;
WCHAR * buttontext[128];
GetWindowThreadProcessId(hToolbar(LPDWORD)pid);
hprocess = (long)OpenProcess(PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_VM_OPERATION,0,pid);
text = (long)VirtualAllocEx((HANDLE)hprocess,0,sizeof(buttontext),MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
for(int i=0;i<cnt;i++)
{
len = SendMessage(hToolbar,TB_GETBUTTONTEXT,i,(LPARAM)text);
if(len>-1)
{
ReadProcessMemory((HANDLE)hprocess, (LPCVOID)text,buttontext,sizeof(buttontext),NULL);
wcout<<buttontext<<"\n";
}
}
I have not been able to get the text and any other message eg:TB_PRESSBUTTON doesn't work either.
Any suggestions?
modified on Friday, July 29, 2011 8:38 AM
|
|
|
|
|
Please edit your question and add <pre> tags around your code to make it more readable.
The best things in life are not things.
|
|
|
|
|
Do some error checking.
It's like a Cataract Operation.
Check return values for error.
Call GetLastError to get the error value.
Use that in the error lookup tool.
All that will give you a lot of information on what is going wrong.
|
|
|
|
|
kartikdasani wrote:
len = SendMessage(hToolbar,TB_GETBUTTONTEXT,i,(LPARAM)text);
The value of i is counting from 0 to TB_BUTTONCOUNT . Are you sure those values match the command identifiers of the buttons on your toolbar? See here[^] for more details. You should also (always) follow Superman[^]'s advice.
The best things in life are not things.
|
|
|
|
|
Hello!
Is it part of the C++ standard that a temporary variable instantiated in the function header is destroyed after a possible assignment operation, so that the following code can be used safely:
class Obj
{
};
Obj& function(Obj& temp = Obj())
{
return temp;
}
int main()
{
Obj myObj;
myObj = function();
return 0;
}
In VC++ 2008, this works as expected. In contrast, when the object is instantiated in the function body, it is destroyed before the assignment operator - so this code is not valid:
Obj& function()
{
Obj temp = Obj();
return temp;
}
Thank you in advance.
Alex
|
|
|
|
|
In the first example you're returning a reference to an object that exists *outside* the function (it was created by the caller, *before* it called the function)
In the second you're returning a reference to something that no longer exists
|
|
|
|
|
Thank you, then it is clear!
Alex
|
|
|
|
|
Hello, I have a problem with overloading operator<< combined with namespaces. The following code compiles OK:
file test_matrix.hpp:
#ifndef TEST_MATRIX_HPP
#define TEST_MATRIX_HPP
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_expression.hpp>
namespace ublas = boost::numeric::ublas;
namespace VecMat {
typedef ublas::matrix<double> MatrixD;
template<class MT>
std::ostream & operator<< (std::ostream & os,
const ublas::matrix_expression<MT> & M)
{
typename MT::const_iterator1 it1;
typename MT::const_iterator2 it2;
for (it1 = M().begin1(); it1 != M().end1(); ++it1) {
for (it2 = it1.begin(); it2 != it1.end(); ++it2) {
os << *it2 << "\t";
}
os << std::endl;
}
return os;
}
}; #endif
file test_oper.cpp:
#include "test_matrix.hpp"
using std::cout;
using std::endl;
using VecMat::MatrixD;
using VecMat::operator<<;
void test1 ();
namespace Main {
void test2 ();
}
void test1 ()
{
MatrixD X(10,3);
VecMat::operator<<(cout << endl, X) << endl;
cout << "X =" << endl << X << endl;
}
void Main::test2 ()
{
MatrixD X(10,3);
VecMat::operator<<(cout << endl, X) << endl;
cout << "X =" << endl << X << endl;
}
However, when I add another class in another namespace, with its own operator<<, then the code stops working.
file test_other.hpp:
#ifndef TEST_OTHER_HPP
#define TEST_OTHER_HPP
#include <ostream>
using std::ostream;
namespace Main {
class Foo {
int n;
};
ostream & operator<< (ostream & os, Foo const & foo);
}
#endif
If I then '#include "test_other.hpp" ' from either of the two original files, the .cpp file won't compile with the following message (gcc):
test_oper.cpp||In function 'void Main::test2()':|
test_oper.cpp|29|error: no match for 'operator<<' in '((std::basic_ostream<char>*)std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char>&)(& std::cout)), ((const char*)"X =")))->std::basic_ostream<_CharT, _Traits>::operator<< [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>](std::endl [with _CharT = char, _Traits = std::char_traits<char>]) << X'|
lib\gcc\mingw32\4.5.2\include\c++\ostream|108|note: candidates are: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]|
...
||=== Build finished: 19 errors, 0 warnings (0 minutes, 1 seconds) ===|
The code fails on the last line, i.e. the explicit call of operator<<() on the next-to-last line works OK - as does using the overloaded operator outside the namespace (in test1() ).
Can anyone explain what is going on here and/or help me to fix this, please?
Thanks in advance.
Michal
|
|
|
|
|
I think the line :
using VecMat::operator<<;
is causing the problem. Try commenting it off and see what happens.
|
|
|
|
|
Sorry, but without it, it won't compile at all (even without the extra file).
|
|
|
|
|
I made the suggestion because I don't believe the using statement is intended for operators. It is for namespaces and I am surprised that it does not result in an error.
|
|
|
|
|
hi every one
i am tried to mapp the large file
SYSTEM_INFO siSysInfo;
DWORD map_data_size;
GetSystemInfo(&siSysInfo);
map_data_size = siSysInfo.dwAllocationGranularity;
HANDLE h_rar_file = CreateFile(filepath,GENERIC_READ | GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,NULL);
HANDLE h_map_file = CreateFileMapping(h_rar_file,NULL, PAGE_READONLY ,ull64FileSize.HighPart,ull64FileSize.LowPart,NULL);
pbuf = (BYTE*) MapViewOfFile(h_map_file, FILE_MAP_READ ,(DWORD)0,0,map_data_size);
it mapping but problem is that
i am traversing till end of the file
first time it will traverse for second time
it wont show the the position pbuf[off_set] its shows the offset value .
help out from this .
because of this my application crashing
|
|
|
|
|
Are you sure that it is the allocation granularity that becomes the number of bytes to map?
What do you mean by traversing for the second time?
Is the traversing done in a loop?
Please post some code where the error actually happens like the traversal code.
On a side note, please always submit code within the code tags.
|
|
|
|
|
ya its allocation granularity that becomes the number of bytes to map
the code very big so i will put where the error is occur ...
while(map_data_size <ull64FileSize.QuadPart)
{
if(pbuf[off_set] == 0x73 && pbuf[off_set + 3]==0x0D)
{.......
off_set++
}
UnmapViewOfFile(pbuf);
map_data_size+=map_data_size;
}
what is the error is the after traversing the offset value is became 1463028177
when it comes to pbuf[off_set] its showing the the error Expression can't be evaluated
help me out of this
|
|
|
|
|
What happens if off_set is the size of pbuf[] ?
Then pbuf[off_set + 3] would overflow the buffer.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
I have created the windows service which does the ShellExecute command on noteapad.exe.
When service is installed the notepad.exe is executed and only seen in task manager. The Notepad.exe window is not visible.
Could anyone let me know what may be the issue with this, I have tried this on Windows XP where it works fine.
Following is the code for SheelExecute
<pre lang="vb">::ShellExecute(NULL,
NULL,
_T("notepad.exe"),
_T("C:\\Users\\testuser\\Desktop\\review_comments.txt"),
_T("C:\\Windows\\System32"),
SW_SHOWMAXIMIZED);</pre>
Thanks in advance
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
From Vista onwards, services are isolated in session 0 and cannot show any UI.
You will need to use CreateProcessAsUser /CreateProcessWithLogonW /CreateProcessWithTokenW APIs to initiate UI application from services.
|
|
|
|
|