|
Thanks cedric,
I realized what I was doing wrong, but I didn't know about 8-byte boundry.
sj
|
|
|
|
|
could you publish the code?
You might consider usage of MS specific __declspec(property) and ignore alignment example
#include <stdexcept>
typedef struct TSimSignal
{
TSimSignal(void * pData = 0) : m_pData(pData){}
__declspec(property(get=GetSimWriteFlag,put=PutSimWriteFlag))
int SimWriteFlag;
__declspec(property(get=GetDisplayReadFlag,put=PutDisplayReadFlag))
int DisplayReadFlag;
__declspec(property(get=GetValue,put=PutValue))
double Value[45];
__declspec(property(get=GetTimeStamp,put=PutTimeStamp))
double TimeStamp;
int GetSimWriteFlag()
{
if(!m_pData)
throw std::out_of_range(__FUNCSIG__);
int * pValue = reinterpret_cast<int*>(m_pData);
return *pValue;
}
void PutSimWriteFlag(int value)
{
if(!m_pData)
throw std::out_of_range(__FUNCSIG__);
int * pValue = reinterpret_cast<int*>(m_pData);
*pValue = value;
}
int GetDisplayReadFlag()
{
if(!m_pData)
throw std::out_of_range(__FUNCSIG__);
int * pValue = reinterpret_cast<int*>(m_pData) + 1;
return *pValue;
}
void PutDisplayReadFlag(int value)
{
if(!m_pData)
throw std::out_of_range(__FUNCSIG__);
int * pValue = reinterpret_cast<int*>(m_pData) + 1;
*pValue = value;
}
double GetValue(long index)
{
if(!m_pData || index < 0 || index >= 45)
throw std::out_of_range(__FUNCSIG__);
double * pArray = reinterpret_cast<double*>(reinterpret_cast<char*>(m_pData) + sizeof(int) * 2);
return pArray[index];
}
void PutValue (long index, double value)
{
if(!m_pData || index < 0 || index >= 45)
throw std::out_of_range(__FUNCSIG__);
double * pArray = reinterpret_cast<double*>(reinterpret_cast<char*>(m_pData) + sizeof(int) * 2);
pArray[index] = value;
}
double GetTimeStamp()
{
if(!m_pData)
throw std::out_of_range(__FUNCSIG__);
double * pValue = reinterpret_cast<double*>(reinterpret_cast<char*>(m_pData) + sizeof(int) * 2 + sizeof(double) * 45);
return *pValue;
}
void PutTimeStamp(double value)
{
if(!m_pData)
throw std::out_of_range(__FUNCSIG__);
double * pValue = reinterpret_cast<double*>(reinterpret_cast<char*>(m_pData) + sizeof(int) * 2 + sizeof(double) * 45);
*pValue = value;
}
protected:
void * m_pData;
}TSimSignal;
|
|
|
|
|
I've posted a couple times before about this problem, and I seemed to be making some progress, but I now seem to have hit a wall. This is for an onscreen keyboard to be used to input text into textboxes in other windows. I'm using a global WH_GETMESSAGE hook to capture messages, and when the message is a WM_LBUTTONDOWN and the window it is being sent to is the keyboard, I use AttachInputThread and a keybd_event to simulate keyboard input. This works, but I have to call SetFocus() every time. Since I am capturing the WM_LBUTTONDOWN message, why is the focus changing? I tried capturing the WM_LBUTTONUP message too, just ignoring it by passing 1 to CallNextHookEx (Yes I pass 1 to CallNextHookEx on the WM_LBUTTONDOWN too...) ... I've tried capturing messages like WM_SETFOCUS, WM_KILLFOCUS, and WM_ACTIVATE... None of those ever seem to actually be called though, or if they are, they aren't being seen by my hook... but its global!!
hook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)MessageProc, hHookDll, 0);
If there is any other snippets of code I can post that might help, let me know. Thanks!
|
|
|
|
|
Perhaps you need to go deeper and earlier in the message sequence. Have a look at WM_NCHITTEST and WM_HITTEST. Good Luck!
onwards and upwards...
|
|
|
|
|
I just set up a CBTProc Hook that prevents the Keyboard window from gaining focus... But now the focus just evaporates! Here is the CBTProc:
<br />
LRESULT CBTHOOK_API CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)<br />
{<br />
<br />
if((nCode == HCBT_SETFOCUS || nCode == HCBT_ACTIVATE) && (HWND)wParam == hKeyWin)<br />
{<br />
return 1;<br />
}<br />
<br />
return CallNextHookEx(HHOOK(0), nCode, wParam, lParam);<br />
}<br />
Where hKeyWin is a handle to the onscreen keyboard. Really, I dont want to keep the keyboard from gaining focus, I want to prevent the last window from losing it... As it stands, it seems that the current window loses focus, and the keyboard is prevented from gaining it, and thus it just evaporates... Like I said, I don't want to re-call SetFocus, I want to prevent the window from ever losing the focus... This is mainly because, in the Internet Explorer Address bar, if you lose focus, and regain it, the text is selected, and what you type is over written, so you cant ever type more than one letter using the onscreen keyboard...
|
|
|
|
|
Maybe you should send a WM_SETCAPTURE to the window which has the focus.
~RaGE();
|
|
|
|
|
WM_ACTIVATE should do it, however ... a window "losing the focus" receives a WM_ACTIVATE with a WA_INACTIVE parameter... A silly question maybe, but are you sure your hook is global ? have you compiled it in the right area using #pragma s ?
~RaGE();
|
|
|
|
|
Heh... Not silly... Because I don't know what a #pragma is I just thought that you had to send SetWindowsHookEx 0 as the last parameter to make it global... So what is this #pragma stuff ?
|
|
|
|
|
... OK ... maybe you should check this article by Joseph M. Newcomer:
Hooks and DLLs[^]
~RaGE();
|
|
|
|
|
Oh .. and a #pragma is a compiler command, mainly to set up a lot of things at compilation time (disabling warnings, choosing memory location for putting your variables, stuff liek that)...
~RaGE();
|
|
|
|
|
We have a LAN and are connected to the internet through a router, how do i get the internet connection ip on one of the computers in the LAN??
Kuniva
--------------------------------------------
|
|
|
|
|
One solution is via registry. Search the registry for the key that holds the system internet IP.
Kuphryn
|
|
|
|
|
Hi,
How can i load a monochrome image from a bmp file ?
Also i want to save the part of that image in an another file. How can i do that?
Regards
Neha
|
|
|
|
|
What do you mean exactly with "Load" ?
Look at the CxImage article here on CP (make a search), it should have all the features you need.
~RaGE();
|
|
|
|
|
Ok, this is kinda intense, but if anyone could help me out, i'd greatly appreciate it. My main problem is that all my integer values for my CEdit boxes are coming up as -858993460. i know whats the default value for an int, but it shouldnt be coming up like that.
Here's whats going on:
i have CPropertySheet class, CMySheet containing 5 CPropertyPage (CPage1 - CPage5) thingies. I have m_page1 - m_page5 defined as CMySheet things. I have m_sh defined as a CMySheet thing in MyProgView.h. now, when i want to get data into an edit box on page1, say its variable name is my_edit, and its an int, then in the constructor for CMyProgView::CMyProgView, i put
CPropsView::CPropsView() : m_sh("")<br />
{<br />
m_sh.m_page1.my_edit= 0;<br />
}
this makes the number 0 show up in the edit boxes. This works fine. However, i'm having trouble with another section. On page4, i have a list of radio buttons. When a user clicks on a button, a new dialog window pops up with some edit boxes.
the dialog boxes are from base class CDialog, they aren't defined as antyhing to do with my CPropertypage or CPropertysheet. I have one dialog box class names New_dialog_box.
Now, here's how i set it up.
in one cpp file, i have the domodal of the dialog box...
<br />
void CPage4::OnBnClickedRadio10()<br />
{<br />
New_dialog_box dlg;<br />
dlg.DoModal();<br />
}
I have a variable defined in New_dialog_box as an integer, its named new_dialog_edit.
Now, back in MyProgVew.h, i tried putting in the constructor of CMyPropgView the line:
m_new_dialog_box.new_dialog_edit = 0;
I declared m_new_dialog_box in
class CPropsView : public CView<br />
{<br />
private:
the exact same spot as m_sh;
I've added m_new_dialog_box(0) to the top of the constructos in MyProgView.cpp, right next to m_sh("").
When i launch the program, go to page4, click on the radio button, the value of new_dialog_edit is teh default value for an integer, -858993460. But, i've set it = 0 in the CMyProgView constructor, just like i did in all the other proeperty pages.
I've been working on this for hours, and i'm really stumped. any help would be hugely appreciated.
*.*
|
|
|
|
|
I'm not sure if I understand your problem very well, but why don't you initialise new_dialog_edit in the constructor of the New_dialog_box class ????
If I understood what you wrote, you have a New_dialog_box variable that is called m_new_dialog_box in your CPropsView but that is never used just in the constructor?? Instead of that, you declare a new instance of New_dialog_box (called dlg) in void CPage4::OnBnClickedRadio10() ??
I don't really understand what you want to do ???
|
|
|
|
|
The instance of New_dialog_box that you have in MyProgView.cpp is not the same one that is instantiated in CPage4::OnBnClickedRadio10().
|
|
|
|
|
keegan wrote:
Now, back in MyProgVew.h, i tried putting in the constructor of CMyPropgView the line:
m_new_dialog_box.new_dialog_edit = 0;
That won't work, I'm even surprised it did not crash, since you obviously try to change values of a CDialog which has still no handle.But anyway, what you should do is set up the edit boxes to 0 in the OnInitDialog function of your dialog class, that is in New_dialog_box::OnInitDialog()
~RaGE();
|
|
|
|
|
i put m_new_dialog_box.new_dialog_edit = 0;
in my onInitDialog for New_dialog_box, but it says that m_new_dialog_box is an undeclared itdentifier. i can't put it in
class New_dialog_box: public CDialog<br />
{<br />
DECLARE_DYNAMIC(New_dialog_box)<br />
<br />
public:<br />
New_dialog_box m_new_dialog_box
if i cant put it there, where else am i going to put it?
THanks for all your responses.
*.*
|
|
|
|
|
What do you want to do there ?? You cannot declare a class within itself !
Just declare a new_dialog_edit variable like this:
class New_dialog_box: public CDialog<br />
{<br />
<br />
public:<br />
int new_dialog_edit;<br />
Then initialize it at 0 in the constructor:
New_dialog_box::New_dialog_box()<br />
{<br />
new_dialog_edit = 0;<br />
...
|
|
|
|
|
holy cow, that works.
Basically, i was getting confused because i was dealing with PreopertySheets in my first case, and normal dialog boxes in the second. I was using m_sh to do something that i don't need to do with just a normal dialog box.
I knew it was something simple, and now i understand what i was doing incorreclty.
thanks
*.*
|
|
|
|
|
I would like some assistance in writting a program that draws a shape in the screen by reading the coordinates of the shape (from a comma delimited ascii file). For example it must read the coordinates of a straight line and automaticaly plot the given line i,e the coordinates 0,0 1,1 2,2 3,3 4,4 should result in a straight line. I'm using ms visual c++ version 6.0
The progoram is coded using the doc/view architecture.
Thanks
|
|
|
|
|
hi there,
first of all u will have to decvide on which event u have to draw i mean after clicking the button oe any thing like that ..
then just read the file and get the point..
the main thing starts here.
what u have to do is create a pen by calling create pen and pass the appropirate parameters.
then get the clientdc .
using the dc please call select object and pass the pen which is created in the above step .
and then using this dc call the function moveto and lineto for drawing a line
bye
TAKE CARE
best luck
Thanx
TAKE CARE
|
|
|
|
|
The MFC sample app Scribble does something very similar to what you are trying to do (though, not from a CSV). It might be worth a look.
onwards and upwards...
|
|
|
|
|
Hello Friends,
I wnat to start my application when ever it detct the live internet connection.
How can i detect the live internet connection?
Thanks
|
|
|
|
|