-
June 16th, 2016, 02:19 PM
#1
[RESOLVED] how can i detect an error?
my aplication seems working normaly, but after same time(not fixed), the program ends and i get:
"Process terminated with status -1073741819 (0 minute(s), 15 second(s))"
i tryied debug it, but the program ends on start:
Building to ensure sources are up-to-date
Selecting target:
Release
Adding source dir: C:\Users\Cambalinho\Documents\CodeBlocks\classcont rols\
Adding source dir: C:\Users\Cambalinho\Documents\CodeBlocks\classcont rols\
Adding file: C:\Users\Cambalinho\Documents\CodeBlocks\classcont rols\bin\Release\classcontrols.exe
Changing directory to: C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols/bin/Release
Set variable: PATH=.;C:\Program Files (x86)\CodeBlocks\mingw32\i686-w64-mingw32\lib;C:\Program Files (x86)\CodeBlocks\mingw32\bin;C:\Program Files (x86)\CodeBlocks\mingw32;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\System32;C:\Windows;C:\Windows\Sys tem32\wbem;C:\Program Files (x86)\PC Connectivity Solution;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Jav a\javapath;C:\Windows\System32\WindowsPowerShell\v 1.0;C:\Program Files\Broadcom\Broadcom 802.11\Driver;C:\Program Files (x86)\Skype\Phone;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files (x86)\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files (x86)\Microsoft Visual Studio\Common\Tools;C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin;C:\Program Files (x86)\Dr. Memory\bin
Starting debugger: C:\Program Files (x86)\CodeBlocks\mingw32\bin\gdb.exe -nx -fullname -quiet -args C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols/bin/Release/classcontrols.exe
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.6
Child process PID: 4056
In ntdll!ZwClose () (C:\Windows\system32\ntdll.dll)
Continuing...
In ntdll!ZwClose () (C:\Windows\system32\ntdll.dll)
Continuing...
[Inferior 1 (process 4056) exited with code 030000000010]
Debugger finished with status 0
and the print screen:
i don't know find these error, can anyone help me?
-
June 16th, 2016, 03:36 PM
#2
Re: how can i detect an error?
I guess you are not alone to get such a code...
Did you try to google for the exited with code 030000000010?
Just try it! Hit: https://www.google.de/search?q=exite...hrome&ie=UTF-8
Victor Nijegorodov
-
June 16th, 2016, 04:15 PM
#3
Re: how can i detect an error?
i had tryied it and with another forums too... but, for now, i don't know a way for try find the error
-
June 16th, 2016, 04:18 PM
#4
Re: how can i detect an error?
Did you try to debug it step-by-step?
Victor Nijegorodov
-
June 16th, 2016, 04:29 PM
#5
Re: how can i detect an error?
Originally Posted by VictorN
Did you try to debug it step-by-step?
is where the error is more faster detected. on 2 step i see the images drawed.. then i see 'ntdll!ZwClose' on next step the Windows 7 give me an error: 'the program stop responding' and then close it
-
June 17th, 2016, 05:40 AM
#6
Re: how can i detect an error?
I can see two ways: 1) remote debug session, or 2) tracing/logging every critical parameter and calculations result, as well as putting assertions wherever it is sensible.
As to the latter, in fact, every our more or less serious project starts with developing an appropriate trace engine. Besides, there was a project where we added taking process mini-dump automatically for post mortem debugging.
Last edited by Igor Vartanov; June 17th, 2016 at 05:49 AM.
Best regards,
Igor
-
June 17th, 2016, 06:04 AM
#7
Re: how can i detect an error?
-1073741819 is C0000005 in hex which is error 5 which is a permission error. I would suspect you have a memory buffer overflow issue somewhere.
Does the error occur before or after main()/winmain() is called? If after then the debug stack should show in which of your functions the error occurs. Once you know this then you can hone in on this function and as Igor suggested in post #6 trace/log everything in that function to determine the issue.
You also might want to consider using a program code analyser which can detect these type of issues.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
June 17th, 2016, 12:36 PM
#8
Re: how can i detect an error?
I'm testing the code, commenting some code.
now i can use debug normaly. when i Click on menu item, i get:
"Program received signal SIGSEGV, Segmentation fault.
In ?? () ()"
what means?
yes i'm using lambdas for the Menu Click and other actions(Mouse Enter and Mouse Leave)
Last edited by Cambalinho; June 17th, 2016 at 12:40 PM.
-
June 17th, 2016, 01:34 PM
#9
Re: how can i detect an error?
thank you to all.
- now i had fixed 1 big error on my Timer class: when i used a not periodic timer(using CreateTimerQueueTimer()), i was stopping the timer on CALLBACK.... now i delete that line and works fine;
- on Debug the Multithread class give me problems with code order, but on normal run, it works... why these problem?(like i said: i only see these problem on Debug);
- what means that error on last post?(again: only happens on Debug)
-
June 18th, 2016, 02:31 PM
#10
Re: how can i detect an error?
For your information, call stack can be saved as plain text. This must be much more effective than posting low resolution pictures in a hope we can see anything there. Man, did you try to read your posts yourself?
Best regards,
Igor
-
June 18th, 2016, 03:25 PM
#11
Re: how can i detect an error?
Originally Posted by Igor Vartanov
For your information, call stack can be saved as plain text. This must be much more effective than posting low resolution pictures in a hope we can see anything there. Man, did you try to read your posts yourself?
what you mean? my english is confused?
-
June 20th, 2016, 02:31 AM
#12
Re: how can i detect an error?
Originally Posted by Cambalinho
what you mean? my english is confused?
Your way of presenting information is confusing. I'm sure you never tried to read anything from the picture after you posted it.
Code:
General
Complete name : J:\My Downloads\program debug error.jpg
Format : JPEG
File size : 41.5 KiB
Image
Format : JPEG
Width : 600 pixels
Height : 337 pixels
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Compression mode : Lossy
Stream size : 41.5 KiB (100%)
It's 600x337 pixels, how could anybody read anything from it? So what was the point of posting anything nobody to be able to read?
And this is what I precisely meant about copying call stack as text:
And this is the result of copying:
Code:
> TestEditBox06142016.exe!CTestEditBox06142016Dlg::OnCtlColor(CDC * pDC, CWnd * pWnd, unsigned int nCtlColor) Line 165 C++
mfc100ud.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2341 + 0x1e bytes C++
mfc100ud.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 + 0x20 bytes C++
mfc100ud.dll!CWnd::OnNTCtlColor(unsigned int wParam, long lParam) Line 1528 C++
mfc100ud.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2383 + 0x11 bytes C++
mfc100ud.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087 + 0x20 bytes C++
mfc100ud.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 + 0x1c bytes C++
mfc100ud.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100ud.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 + 0x15 bytes C++
user32.dll!gapfnScSendMessage() + 0x332 bytes
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
user32.dll!GetThreadDesktop() + 0xd7 bytes
user32.dll!GetWindow() + 0x3f0 bytes
user32.dll!SendMessageW() + 0x4c bytes
comctl32.dll!SizeBoxHwnd() + 0x7b34 bytes
comctl32.dll!SizeBoxHwnd() + 0x7ade bytes
comctl32.dll!SizeBoxHwnd() + 0x3bfe bytes
comctl32.dll!SizeBoxHwnd() + 0x9352 bytes
user32.dll!gapfnScSendMessage() + 0x332 bytes
user32.dll!GetThreadDesktop() + 0xd7 bytes
user32.dll!GetClientRect() + 0xc5 bytes
user32.dll!CallWindowProcW() + 0x1b bytes
mfc100ud.dll!CWnd::DefWindowProcW(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 + 0x20 bytes C++
mfc100ud.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2088 + 0x1c bytes C++
mfc100ud.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 + 0x1c bytes C++
mfc100ud.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100ud.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 + 0x15 bytes C++
user32.dll!gapfnScSendMessage() + 0x332 bytes
user32.dll!GetDC() + 0x52 bytes
user32.dll!GetThreadDesktop() + 0x18a bytes
user32.dll!GetThreadDesktop() + 0x1e9 bytes
ntdll.dll!KiUserCallbackDispatcher() + 0x2e bytes
comctl32.dll!SizeBoxHwnd() + 0x9250 bytes
comctl32.dll!DPA_Clone() + 0x33fe bytes
user32.dll!gapfnScSendMessage() + 0x332 bytes
user32.dll!GetThreadDesktop() + 0xd7 bytes
user32.dll!GetClientRect() + 0xc5 bytes
user32.dll!CallWindowProcW() + 0x1b bytes
mfc100ud.dll!CWnd::DefWindowProcW(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 + 0x20 bytes C++
mfc100ud.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2088 + 0x1c bytes C++
mfc100ud.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257 + 0x1c bytes C++
mfc100ud.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
mfc100ud.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 + 0x15 bytes C++
user32.dll!gapfnScSendMessage() + 0x332 bytes
user32.dll!GetDC() + 0x52 bytes
user32.dll!GetThreadDesktop() + 0x18a bytes
user32.dll!GetThreadDesktop() + 0x1e9 bytes
ntdll.dll!KiUserCallbackDispatcher() + 0x2e bytes
user32.dll!IsCharAlphaA() + 0x29f2 bytes
user32.dll!CreateDialogIndirectParamAorW() + 0x33 bytes
user32.dll!CreateDialogIndirectParamW() + 0x1b bytes
mfc100ud.dll!CWnd::CreateDlgIndirect(const DLGTEMPLATE * lpDialogTemplate, CWnd * pParentWnd, HINSTANCE__ * hInst) Line 366 + 0x2a bytes C++
mfc100ud.dll!CDialog::DoModal() Line 630 + 0x20 bytes C++
TestEditBox06142016.exe!CTestEditBox06142016App::InitInstance() Line 63 + 0xb bytes C++
mfc100ud.dll!AfxWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 37 + 0xd bytes C++
TestEditBox06142016.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 26 C++
TestEditBox06142016.exe!__tmainCRTStartup() Line 547 + 0x2c bytes C
TestEditBox06142016.exe!wWinMainCRTStartup() Line 371 C
kernel32.dll!BaseThreadInitThunk() + 0x12 bytes
ntdll.dll!RtlInitializeExceptionChain() + 0x63 bytes
ntdll.dll!RtlInitializeExceptionChain() + 0x36 bytes
Now please tell me what is more easy to read, your picture or my text block?
Last edited by Igor Vartanov; June 20th, 2016 at 02:52 AM.
Best regards,
Igor
-
June 20th, 2016, 12:34 PM
#13
Re: how can i detect an error?
i'm sorry. you have right. I didn't notice about the image size. i'm so sorry.
when i click on menu item for end.
Code:
void End()
{
if(hhookCBTProc!=0)
UnhookWindowsHookEx(hhookCBTProc);
PostQuitMessage(0);
}
Call stack:
#0 34808BC4 ?? () (??:??)
#1 00456AE2 std::function<void ()>:: operator()() const () (??:??)
#2 004298A4 form::WndProcForm () (??:??)
#3 759962FA gapfnScSendMessage() (C:\Windows\syswow64\user32.dll:??)
#4 0008053C ?? () (??:??)
#5 0000011F ?? () (??:??)
#6 FFFF0000 ?? () (??:??)
#7 ?? ?? () (??:??)
if i click on continue, these will change until the OS system give me an error: "the program stopped responding".
so what i'm doing wrong? is my End() function or anotherthing?
-
June 20th, 2016, 12:38 PM
#14
Re: how can i detect an error?
debugger:
"Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\
Adding source dir: C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\
Adding file: C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\bin\Debug\classcontrols.exe
Changing directory to: C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols/bin/Debug
Set variable: PATH=.;C:\Program Files (x86)\CodeBlocks\mingw32\i686-w64-mingw32\lib;C:\Program Files (x86)\CodeBlocks\mingw32\bin;C:\Program Files (x86)\CodeBlocks\mingw32;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Program Files (x86)\PC Connectivity Solution;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Broadcom\Broadcom 802.11\Driver;C:\Program Files (x86)\Skype\Phone;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files (x86)\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files (x86)\Microsoft Visual Studio\Common\Tools;C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin;C:\Program Files (x86)\Dr. Memory\bin
Starting debugger: C:\Program Files (x86)\CodeBlocks\mingw32\bin\gdb.exe -nx -fullname -quiet -args C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols/bin/Debug/classcontrols.exe
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.6
Child process PID: 3212
Program received signal SIGSEGV, Segmentation fault.
In ?? () ()
Continuing...
In ntdll!ZwClose () (C:\Windows\system32\ntdll.dll)
Continuing...
Program received signal SIGSEGV, Segmentation fault.
In consolewindow::mtRead::{lambda(void*)#1}:: operator()(consolewindow::mtRead) const () ()
Continuing...
Program received signal SIGSEGV, Segmentation fault.
In consolewindow::mtRead::{lambda(void*)#1}:: operator()(consolewindow::mtRead) const () ()
Continuing...
Program received signal SIGSEGV, Segmentation fault.
In consolewindow::mtRead::{lambda(void*)#1}:: operator()(consolewindow::mtRead) const () ()
Continuing...
[Inferior 1 (process 3212) exited with code 030000000010]
Debugger finished with status 0"
-
June 26th, 2016, 10:27 AM
#15
Re: how can i detect an error?
i had some problems on my consolewindow so see the desconstructor:
Code:
class consolewindow
{
HWND consoleedit=NULL;
form frmconsolewindow{"console"};
COLORREF clrTextColor=RGB(255,255,255);
COLORREF clrTextBackColor=RGB(0,0,0);
protected: bool blnread=false;
protected: string readstring="";
Timer tmrCreate={[&](){if(Create)Create();}};
struct strucread
{
LPVOID varadress=NULL;
string vartype="";
variant varvalue="";
};
vector<strucread> readdata;
//these constructor function works fine for a string, but not for a numbers or char* :(
Multithread mtRead{ [&]( LPVOID varname)
{
strucread *strTest=static_cast<strucread*>(varname);
if(strTest->vartype!="write")// && strTest->vartype!="write: string" && strTest->vartype!="write: double" && strTest->vartype!="write: float" && strTest->vartype!="write: char*" && strTest->vartype!="write: const char*" && strTest->vartype!="write: char" && strTest->vartype!="write: const char")
{
blnread=true;
}
while(blnread==true)
{
MSG TMsg;
do
{
if(blnread==false)
break;
TranslateMessage(&TMsg);
if(blnread==false)
break;
DispatchMessage(&TMsg);
if(blnread==false)
break;
}
while (PeekMessage(&TMsg, 0, 0, 0, true) || (blnread==true));
}
if(strTest->vartype=="string")
*((string*)(strTest->varadress)) = readstring;
else if(strTest->vartype=="char*")
{
char *cstr = new char[readstring.length() + 1];
strcpy(cstr, readstring.c_str());
*((char*)(strTest->varadress)) =cstr[0];
delete [] cstr;
}
else if(strTest->vartype=="char")
{
char cstr = readstring[0];
*((char*)(strTest->varadress)) =cstr;
}
else if(strTest->vartype=="double")
{
if(is_number(readstring)==true)
{
*((double*)(strTest->varadress)) = stof(readstring);
}
else
{
*((double*)(strTest->varadress)) =0;
}
}
else if(strTest->vartype=="int")
{
if(is_number(readstring)==true)
{
*((int*)(strTest->varadress)) = stoi(readstring);
}
else
{
*((int*)(strTest->varadress)) =0;
}
}
else if(strTest->vartype=="variant")
*((variant*)(strTest->varadress)) = readstring;
else if(strTest->vartype=="write")
{
SendMessage(consoleedit, EM_REPLACESEL, 0, (LPARAM)(char*)strTest->varvalue);
}
readstring="";
}};
bool blnShowCaret=true;
COORD getlastcursorpos{0};
WNDPROC wpOrigRichEditProc;
static LRESULT APIENTRY RichEditProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
consolewindow *richedit = (consolewindow *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch(uMsg)
{
case WM_CREATE:
{
richedit->ShowCaret(true);
}
break;
case WM_KEYDOWN:
{
if((wParam==VK_BACK) && (richedit->blnread==true))
{
if(richedit->readstring.size()>=1)
{
richedit->readstring.pop_back();
}
else if (richedit->readstring.size()==0)
return 0;
}
else if(((wParam==VK_BACK) || (wParam==VK_RETURN)) && (richedit->blnread==false))
return 0;
}
break;
case WM_RBUTTONUP:
{
richedit->ShowCaret(!richedit->ShowCaret());
}
break;
/*case WM_COMMAND:
{
image imgtext(10,10);
pen pnCaret(0,2,RGB(255,0,0));
imgtext.TextColor(RGB(255,0,0));
imgtext.DrawText("H");
if(::DestroyCaret())
DebugText("error: not destroyed");
if(::CreateCaret (richedit->consoleedit, imgtext, 0, 0)==FALSE)
DebugText("error: not created");
if(::ShowCaret(richedit->consoleedit))
DebugText("error: not showed");
DebugText(to_string(GetCaretBlinkTime()));
//return 0;
}
break;*/
case WM_KEYUP:
{
if((wParam==VK_RETURN) && (richedit->blnread==true))
{
richedit->blnread=false;
}
else if((wParam==VK_RETURN) && (richedit->blnread==false))
return 0;
}
break;
case WM_PAINT:
{
if(richedit->Paint!=NULL)
{
richedit->ShowCaret(false);
PAINTSTRUCT ps;
BeginPaint(richedit->consoleedit,&ps);
string windowtext;
GetWindowString(richedit->consoleedit,windowtext);
RECT textrect;
DrawText(ps.hdc,windowtext.c_str(),-1,&textrect,DT_EXPANDTABS | DT_CALCRECT);
if(DrawText(ps.hdc,windowtext.c_str(),-1,&textrect,DT_EXPANDTABS)==0)
DebugText("error not text");
richedit->Paint(richedit->consoleedit,ps.hdc);
EndPaint(richedit->consoleedit,&ps);
}
}
break;
case WM_CHAR:
{
if(richedit->blnread==true && wParam!=VK_BACK)
{
richedit->readstring=richedit->readstring + char(wParam);
}
else
return 0;
}
break;
}
return CallWindowProc(richedit->wpOrigRichEditProc,hwndDlg,uMsg,wParam,lParam);
}
public:
event(Paint,(HWND hwndWindow, HDC hdcWindow))=nullptr;
event(Create)=nullptr;
event(GetFocus)=nullptr;
consolewindow(string strTitle="")
{
static int i=0;
i=i+1;
if(strTitle=="")
strTitle="Console " + to_string(i);
frmconsolewindow.Text=strTitle;
LoadLibrary(TEXT("Msftedit.dll"));
consoleedit = CreateWindowEx(WS_EX_NOACTIVATE,"RICHEDIT50W", TEXT(""),
WS_CHILD | WS_VISIBLE | ES_WANTRETURN | ES_MULTILINE | ES_AUTOHSCROLL|ES_AUTOVSCROLL | WS_VSCROLL | WS_HSCROLL, 0, 0,
frmconsolewindow.width-16, frmconsolewindow.height -38 , frmconsolewindow, 0, GetModuleHandle(0), 0 ) ;
wpOrigRichEditProc=(WNDPROC)SetWindowLong(consoleedit,GWL_WNDPROC,(LONG_PTR)consolewindow::RichEditProc);
SetWindowLongPtr(consoleedit,GWLP_USERDATA,(LONG) this);
SendMessage( consoleedit, EM_SETBKGNDCOLOR, 0, RGB( 0,0,0 ) );
CHARFORMAT2 cf;
cf.dwEffects =0;
cf.dwMask = CFM_COLOR;
cf.crTextColor =RGB(255,255,255);
cf.cbSize = sizeof(CHARFORMAT2);
SendMessageA(consoleedit, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf );
//SetFocus(consoleedit);
frmconsolewindow.Resize=[&]()
{
SetWindowPos(consoleedit,0,0,0,frmconsolewindow.width-16, frmconsolewindow.height -38 ,SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOZORDER);
};
frmconsolewindow.Close=[&]()
{
blnread=false;
};
readdata.resize(100);
mtRead.SingleThreadAtTime(true);
frmconsolewindow.GetFocus=[&]()
{
SetFocus(consoleedit);
ShowCaret(true);
if(GetFocus)
{
GetFocus();
}
};
tmrCreate.Interval=100;
tmrCreate.Start(false);
}
void SetCaretPos(COORD pos)
{
LONG characterIndexLine =0;
characterIndexLine=(LONG) SendMessage(consoleedit, EM_LINEINDEX, (WPARAM) pos.Y-1,0);
characterIndexLine+=(LONG)pos.X;
CHARRANGE cr;
cr.cpMin = characterIndexLine;
cr.cpMax = characterIndexLine;
SendMessage(consoleedit, EM_EXSETSEL, 0, (LPARAM)&cr);
}
COORD GetCaretPos( )
{
COORD pos;
//getting the line where is the caret(WPARAM is -1 for the caret position):
pos.Y=(LONG) SendMessage(consoleedit, EM_LINEFROMCHAR,(WPARAM)-1,0)+1;
//getting the caret on text position:
CHARRANGE cr;
cr.cpMin = 0;
cr.cpMax = 0;
SendMessage(consoleedit, EM_EXGETSEL, 0, (LPARAM)&cr);
//getting the 1st charater line position(is gived on text position). for use the caret position, we can use -1:
LONG firstcharacter=SendMessage(consoleedit, EM_LINEINDEX, (WPARAM)-1,0);
//the caret text position minus the 1st character on that line, will give me the x:
pos.X=cr.cpMin-firstcharacter;
return pos;
}
bool ShowCaret()
{
return blnShowCaret;
}
void ShowCaret(bool blShowCaret)
{
blnShowCaret=blShowCaret;
if(blShowCaret==false)
{
getlastcursorpos=GetCaretPos();
DestroyCaret();
}
else
{
CreateCaret(consoleedit,NULL,0,0);
SetCaretPos(getlastcursorpos);
}
}
void refresh()
{
InvalidateRect(consoleedit,NULL,FALSE);
}
void clear()
{
SetWindowText(consoleedit,"");
}
void SetBackGroundColor(COLORREF clrBackGround)
{
SendMessage(consoleedit, EM_SETBKGNDCOLOR, 0,clrBackGround);
}
void SetTextBackColor(COLORREF clrtxtColor, COLORREF clrBackColor=-1)
{
clrTextColor=clrtxtColor;
if(clrBackColor!=-1)
clrTextBackColor=clrBackColor;
}
operator HWND()
{
return frmconsolewindow;
}
void read()
{
//nothing
}
int i=-1;
void read(variant &vrtValue)
{
//alterar o formato e a cor de texto
CHARFORMAT2 cf ;
cf.cbSize = sizeof( CHARFORMAT2 ) ;
cf.dwMask = CFM_COLOR | CFM_BACKCOLOR | CFM_EFFECTS2 ;
cf.crTextColor =clrTextColor;
cf.dwEffects =0;
cf.crBackColor = clrTextBackColor;
SendMessage(consoleedit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf );
i=i+1;
readdata[i].varadress=&vrtValue;
readdata[i].vartype="variant";
mtRead(&readdata[i]);
if(i==100)
i=-1;
}
void read(string &txttext)
{
//alterar o formato e a cor de texto
CHARFORMAT2 cf ;
cf.cbSize = sizeof( CHARFORMAT2 ) ;
cf.dwMask = CFM_COLOR | CFM_BACKCOLOR | CFM_EFFECTS2 ;
cf.crTextColor =clrTextColor;
cf.dwEffects =0;
cf.crBackColor = clrTextBackColor;
SendMessage(consoleedit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf );
i=i+1;
readdata[i].varadress=&txttext;
readdata[i].vartype="string";
mtRead(&readdata[i]);
if(i==100)
i=-1;
}
void read(char txttext[])//corrigir
{
CHARFORMAT2 cf ;
cf.cbSize = sizeof( CHARFORMAT2 ) ;
cf.dwMask = CFM_COLOR | CFM_BACKCOLOR | CFM_EFFECTS2 ;
cf.crTextColor =clrTextColor;
cf.dwEffects =0;
cf.crBackColor = clrTextBackColor;
SendMessage(consoleedit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf );
i=i+1;
readdata[i].varadress=&txttext;
readdata[i].vartype="char*";
mtRead(&readdata[i]);
if(i==100)
i=-1;
}
void read(double &txttext)//corrigir
{
CHARFORMAT2 cf ;
cf.cbSize = sizeof( CHARFORMAT2 ) ;
cf.dwMask = CFM_COLOR | CFM_BACKCOLOR | CFM_EFFECTS2 ;
cf.crTextColor =clrTextColor;
cf.dwEffects =0;
cf.crBackColor = clrTextBackColor;
SendMessage(consoleedit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf );
i=i+1;
readdata[i].varadress=&txttext;
readdata[i].vartype="double";
mtRead(&readdata[i]);
if(i==100)
i=-1;
}
void read(int &txttext)//corrigir
{
CHARFORMAT2 cf ;
cf.cbSize = sizeof( CHARFORMAT2 ) ;
cf.dwMask = CFM_COLOR | CFM_BACKCOLOR | CFM_EFFECTS2 ;
cf.crTextColor =clrTextColor;
cf.dwEffects =0;
cf.crBackColor = clrTextBackColor;
SendMessage(consoleedit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf );
i=i+1;
readdata[i].varadress=&txttext;
readdata[i].vartype="int";
mtRead(&readdata[i]);
if(i==100)
i=-1;
}
template<typename first_t, typename... rest_t>
void read(first_t &first, rest_t... rest)
{
read(first);
read(rest...); //function is recursive
//when the parameter pack becomes empty
//write(); will be called with no parameters
//which is why we declare it above
}
//write:
void write(variant strText)
{
CHARFORMAT2 cf ;
cf.cbSize = sizeof( CHARFORMAT2 ) ;
cf.dwMask = CFM_COLOR | CFM_BACKCOLOR | CFM_EFFECTS2 ;
cf.crTextColor =clrTextColor;
cf.dwEffects =0;
cf.crBackColor = clrTextBackColor;
SendMessage(consoleedit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf );
i=i+1;
readdata[i].vartype="write";
readdata[i].varvalue=strText;
mtRead(&readdata[i]);
if(i==100)
i=-1;
}
void write()
{
//nothing
}
template<typename first_t, typename... rest_t>
void write(first_t first, rest_t... rest)
{
write((variant)first);
write(rest...);
}
~consolewindow()
{
for(int i=0; i<10; i++)
{
blnread=false;
mtRead.SetCondition();
Sleep(25);
}
}
};
the mtRead it's my Multithread object. the read() is called 3 times(on these sample), so i must use that for... i use, for now, a magic number, in time i will resolve it with another variable
my menus(system and tollbar) was give me problems to, so i fixed them:
Code:
case WM_MENUCOMMAND:
{
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask=MIIM_DATA;
if(GetMenuItemInfo((HMENU)lParam,(UINT) wParam, TRUE, &menuInfo )!=FALSE) //see these if
{
Menu *mMenu = (Menu *) menuInfo.dwItemData;
if(mMenu!=NULL && mMenu->ispopup==false)
{
if(mMenu->Click)
mMenu->Click();
//mMenu->imgMenu.reset();
}
return 0;
}
//menuhandle=NULL;
}
break;
//when the mouse move, enter, leave and leave the menu
static Menu *mMenu=NULL;
static UINT Last_Menu_ID=-1;
case WM_MENUSELECT:
{
//menuhandle=(HMENU)lParam;
//mouse leave the previous menu item
if(GetMenuState((HMENU)lParam,Last_Menu_ID,MF_BYCOMMAND)!=-1)
{
if (mMenu!=NULL)
{
if(mMenu->MouseLeave)
mMenu->MouseLeave();
mMenu=NULL;
}
Last_Menu_ID=-1;
}
if( ((HIWORD(wParam) & MF_POPUP)==MF_POPUP) && (HIWORD(wParam) & MF_MOUSESELECT))
{
MENUITEMINFO menuInfo1;
menuInfo1.cbSize = sizeof(MENUITEMINFO);
menuInfo1.fMask=MIIM_DATA;
if(GetMenuItemInfo((HMENU)lParam,LOWORD(wParam), TRUE, &menuInfo1 )==FALSE) //see these if
break;
mMenu = (Menu *) menuInfo1.dwItemData;
if (mMenu!=NULL)
{
if(mMenu->MouseEnter)
mMenu->MouseEnter();
}
Last_Menu_ID = LOWORD(wParam);
}
else if(((HIWORD(wParam) & MF_HILITE) || (HIWORD(wParam) & MF_MOUSESELECT)) && ((HIWORD(wParam) & MF_POPUP)!=MF_POPUP))
{
//Mouse Enter on actual menu item
MENUITEMINFO menuInfo1;
menuInfo1.cbSize = sizeof(MENUITEMINFO);
menuInfo1.fMask=MIIM_DATA;
if(GetMenuItemInfo((HMENU)lParam,LOWORD(wParam), FALSE, &menuInfo1 )==FALSE) //see these if
break;
mMenu = (Menu *) menuInfo1.dwItemData;
if (mMenu!=NULL)
{
if(mMenu->MouseEnter)
mMenu->MouseEnter();
}
Last_Menu_ID = LOWORD(wParam);
menuhandle=(HMENU)lParam ;
}
return 0;
}
break;
//some menus items are on system menu control
case WM_SYSCOMMAND:
{
//testing if the menu handle isn't null and if the menu item is valid
if (GetMenuState(menuhandle,wParam,MF_BYCOMMAND) !=0xFFFFFFFF && menuhandle!=NULL )
{
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask=MIIM_DATA;
GetMenuItemInfo(menuhandle,(UINT) wParam, FALSE, &menuInfo );
Menu *mMenu = (Menu *) menuInfo.dwItemData;
if (mMenu!=NULL && mMenu->ispopup==false)
{
if(mMenu->Click)
mMenu->Click();
//mMenu->imgMenu.reset();
//return 0;
}
}
//menuhandle=NULL;
else
return DefWindowProc(HandleWindow, msg, wParam, lParam);
}
break;
readers: please test the API functions returning value, or you can get problems\errors that are very dificulty to find them(see the commented if's)
now i have another diferent errors that i don't know them:
Program received signal SIGSEGV, Segmentation fault.
In ntdll!RtlInitUnicodeString () (C:\Windows\system32\ntdll.dll)
Continuing...
Program received signal SIGSEGV, Segmentation fault.
In ntdll!RtlInitUnicodeString () (C:\Windows\system32\ntdll.dll)
Continuing...
Program received signal SIGTRAP, Trace/breakpoint trap.
In ntdll!RtlpNtEnumerateSubKey () (C:\Windows\system32\ntdll.dll)
Continuing...
[Inferior 1 (process 2352) exited with code 030000000005]
Debugger finished with status 0
so what means 'RtlpNtEnumerateSubKey' and 'RtlInitUnicodeString'?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|