|
|
hello i have add to my dialogBar one slider a i want to get the value of the slider when it move and i have add one variable RequiredCharacter :
void MyDialogBar::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) <br />
{<br />
if(pScrollBar)<br />
{<br />
CSliderCtrl * pSlider = (CSliderCtrl*)pScrollBar;<br />
<br />
if(pSlider->GetDlgCtrlID() == IDC_SLIDER1)<br />
{<br />
CString str;<br />
str.Format("%d", pSlider->GetPos());<br />
GetDlgItem(IDC_EDIT1)->SetWindowText(str);<br />
<br />
<br />
RequiredCharacter =pSlider->GetPos();<br />
<br />
<br />
}<br />
}<br />
CDialogBar::OnHScroll(nSBCode, nPos, pScrollBar); <br />
<br />
}<br />
<br />
and in App class i want to compare this value(of the slider when it move)
like this :
<br />
if(PtrDialogBar->RequiredCharacter > ptrScene->CharacterPos.size())<br />
{<br />
int amoun = PtrDialogBar->RequiredCharacter - ptrScene->CharacterPos.size();<br />
ptrScene->AddCharacter(amoun);<br />
}
PtrDialogBar is a pointer from the class when it was declared RequiredCharacter because it's note in the same class
CharacterPos it's a vector of structur
but it don't give any value when i scroll the slider ,can you hel me please?
|
|
|
|
|
where can i get a list of identifyers like char, int, sizeof, or whatever ya call em
|
|
|
|
|
|
|
Hi,
Ok here is the situation:
I have a piece of code which needs to save debug dumps during runtime for that I use MiniDumpWriteDump() function in an __except() block, because I need to call GetExceptionInformation() to receieve EXCEPTION_POINTERS.I also need to catch CMemoryException but as you know for that I must use catch() instead of __except(). And if I use that I wouldn't be able to call GetExceptionInformation().
So my question is how can I catch CMemoryExcpetion in an __except block or alternatively, how can I receive EXCEPTION_POINTER in a catch() block?
Any help appreciated!!!
Rob
|
|
|
|
|
Use standard try and catch and resort to _set_se_translator to transform SEH exceptions into C++ exceptions, just like the following code shows:
class SEH_exception:public std::runtime_error
{
public:
SEH_exception(unsigned int code,const char* msg):std::runtime_error(msg),code_(code){}
unsigned int code()const{return code_;}
private:
unsigned int code_;
};
static void SEH_translator(unsigned int code,EXCEPTION_POINTERS*)
{
std::string msg;
switch(code){
case EXCEPTION_ACCESS_VIOLATION: msg="access violation";break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: msg="array bounds exceeded";break;
case EXCEPTION_BREAKPOINT: msg="breakpoint exception";break;
case EXCEPTION_DATATYPE_MISALIGNMENT: msg="datatype misalignment";break;
case EXCEPTION_FLT_DENORMAL_OPERAND: msg="flt denormal operand";break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO: msg="flt divide by zero";break;
case EXCEPTION_FLT_INEXACT_RESULT: msg="flt inexact result";break;
case EXCEPTION_FLT_INVALID_OPERATION: msg="flt invalid operation";break;
case EXCEPTION_FLT_OVERFLOW: msg="flt overflow";break;
case EXCEPTION_FLT_STACK_CHECK: msg="flt stack check";break;
case EXCEPTION_FLT_UNDERFLOW: msg="flt underflow";break;
case EXCEPTION_ILLEGAL_INSTRUCTION: msg="illegal instruction";
case EXCEPTION_IN_PAGE_ERROR: msg="in page error";break;
case EXCEPTION_INT_DIVIDE_BY_ZERO: msg="divide by zero";break;
case EXCEPTION_INT_OVERFLOW: msg="overflow"; break;
case EXCEPTION_INVALID_DISPOSITION: msg="invalid disposition";break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION: msg="noncontinuable exception";break;
case EXCEPTION_PRIV_INSTRUCTION: msg="priv instruction";break;
case EXCEPTION_SINGLE_STEP: msg="single step trap";break;
case EXCEPTION_STACK_OVERFLOW: msg="stack overflow";break;
default:{
char buf[1024];
sprintf(buf,"SEH exception (%x)",code);
msg=buf;
}
break;
}
throw SEH_exception(code,msg.c_str());
}
...
_set_se_translator(SEH_translator);
...
try{
...
}
catch(SEH_exception& e){
...
}
catch(CMemoryException& e){
...
} I guess you can modify the example given to suit your needs. Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks that helped alot!
|
|
|
|
|
Hi!
I've created an SDI application with a formview for its view. My formview is bigger than the screen, so I would like to add a vertical scrollbar.
Is there a way to automaticaly add a scrollbar to move the formview? If not, how to manualy add it?
Thks in advance!
Appstmd
http://www.appstmd.com
|
|
|
|
|
THe formview should have a scroll bar automatically. The onyl times it will not is if you are calling SetScrollSizeToFit() on the form view. Thsi function is used to set the x/y dimension of the form before a scroll bar appears. By default the size of the formview in the resource editor is used as the default size of the form. If the screen real-esatet is less then this then you get your scroll bars.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Thks for your answer. But in fact, because I've got several views, my view is derived from CView and not from CFormView, and I manually add a dialog on the view. The user can choose another mode, and another dialog is displayed on the view.
Can I automatically display a scrollbar in this way?
Thks in advance!
Appstmd
http://www.appstmd.com
|
|
|
|
|
I am creating a control that has a treeview.
I am trying to capture the OnNotify with
NMHDR *phdr = (NMHDR *)lParam;
// Coming from listview?
if( phdr->code == NM_RCLICK )
MessageBox(NULL, "Right click found", "Click", MB_OK);
but i am only getting the calls when the mouse is clicked on the header, same goes for Double click, what am I doing wrong,
any help is really appreciated
shotgun
|
|
|
|
|
I assume you mean a list view, since a tree doesn't have a header.
WM_NOTIFY messages go to the parent of the control, so when you r-click the list, the message goes to the list's parent. This is why you get a message when you r-click the header; the message goes to the header's parent, which is the list.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
I want to search through a directory and get all the files and subdirectories in it. I can't seem to get subdirectores using CFileFind, just files, so I was wondering if there was another way to do this.
Thanks
|
|
|
|
|
One solution is FindFirstFile() and FindNextFile(). Determine the file attribute to distinguish folders from files.
Kuphryn
|
|
|
|
|
I tried that and whenever it got a folder, and I tried to display the name of the folder, it was just a period. I'll give that another try though.
|
|
|
|
|
Yeah. Those functions could return periods, which indicate parent folder.
Kuphryn
|
|
|
|
|
Change the function you are using to scan through a folder to a recursive one. Whenever you encounter a folder, call that function again with the sub folder path. I have done this and it works.
|
|
|
|
|
Hi.
I have this class:
<br />
class CNetwork<br />
{<br />
public:<br />
void InitNetwork();<br />
DWORD WINAPI ListningForClients(LPVOID Arg1);<br />
void SendToClient(CLIENTS TheClient,char *Command);<br />
<br />
<br />
private:<br />
char ServerAddress[64];<br />
int ServerPort;<br />
struct hostent *ServerHost;<br />
int nReturn;<br />
<br />
SOCKET s; <br />
WSADATA wsda; <br />
SOCKET sListen, sClient;<br />
SOCKADDR_IN addr, RemoteAddress; <br />
};<br />
But I'm having some problems with the DWORD WINAPI ListingForClients call
DWORD WINAPI ListningForClients(LPVOID Arg1)<br />
{ <br />
......<br />
if (NumClientsConnected < MaxConnections)<br />
{<br />
CreateThread( NULL, 0, &ListningForClients, 0, 0, 0);<br />
}<br />
......<br />
}
This ofcourse calls itself, theirby creating a new thread..
But i'm getting this error when compiling.
CNetwork.cpp(42) : error C2276: '&' : illegal operation on bound member function expression
The function works when it's not incapsueled in a class!!
Thank for anyhelp.
|
|
|
|
|
Make ListningForClients static . For further info on callbacks over member functions, check Mike Dunn's C++ FAQ (top of this page), paragraph 6.1.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Okay I tried to make it static. but now i get some errors:
example: illegal reference to data member 'CNetwork::sListen' in a static member function
Might I ask, what does Static do?
|
|
|
|
|
Well, Mike's FAQ explains it all, but I'll try to clear the issue up myself. Non-static members have, so to say, a hidden parameter pointing to the object the member function applies to (the this parameter, if you want to see it like that). After changing ListningForClients to static , the member function is no longer bound to any particular object via this , hence the error. This is what static means when applies to member functions: general functions not associated to particular instances of the class.
The way out of this problem is to use a callback paramter CreateThread provides just for this sort of things. In this parameter you can store a pointer to the relevant object and then use it accordingly. Pseudocode follows:
class CNetwork
{
...
static DWORD WINAPI StaticListeningForClients(LPVOID Arg1)
{
CNetwork* object=(CNetwork*)(Arg1);
object->ListeningForClients();
}
void ListeningForClients()
{
}
...
CreateThread( NULL, 0, &ListeningForClients, this, 0, 0);
}; Hope you get the idea. Please read the FAQ for further clarification. Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
The problem is that you do not need to pass the Address of the the function ListenForClients, because ListenForClients as a symbol is already an address.
Just get rid of the ampersand.
CreateThread( NULL, 0, ListeningForClients, this, 0, 0);
|
|
|
|
|
How can I open an .exe file to see the actual code?
Alex
|
|
|
|
|
Use Visual Studio. Open as binary.
|
|
|
|