 |

|
Hi.. i have used the structure to pass three different variable as shown below...
int main()
{
struct result t1;
t1 = my_encrypt();
cout << t1.pa << t1.c1 << t1.c2 <<;
}
struct result my_encrypt()
{
typedef EllipticCurve<263> ec_t;
struct result
{
ec_t::Point Pa;
ec_t::ffe_t c1;
ec_t::ffe_t c2;
}t;
ec_t::Point Pk = a*Pb;
ec_t::ffe_t t.c1( m1*Pk.x() );
ec_t::ffe_t t.c2( m2*Pk.y() );
return (t);
}
I am getting so many errors.. Please tell me anything wrong declaration here.
Can i declare that structure as global...
|
|
|
|

|
Quote: int main()
{
struct result t1;
t1 = my_encrypt(); Should be:
int main()
{
struct result t1 = {0};
my_encrypt(&t1);
Quote: struct result my_encrypt()
{ should be:
int my_encrypt(struct result * pt1)
{
Please note, there are other (unrelated) errors in your code.
Veni, vidi, vici.
|
|
|
|

|
I am trying to create a dialog MFC application that reads the cursor position anywhere on the screen, finds the colour of the pixel at that location and reports the information back to the dialog application.
I have tried SetCapture and I must be doing something wrong because the cursor location stops reporting as soon as the cursor leaves the client area of the dialog. I have also looked at the "Screen Color Picker" by Florin Vasilescu. That uses an OnTimer function that allows me to read the screen location, but does not report mouse actions (LBUTTONDOWN) so that I can read the pixel at the cursor location.
I have also tried using SetWindowsHookEx and defining the MouseProc (as described by Vesi in the CodeGuru article "Modal dialog and outside mouse control". That wasn't successful. If I use the WH_JOURNALRECORD hook ID as described there appears to be an indeterminate delay between any mouse (or keyboard) action and interaction with screen objects. If I use the WH_MOUSE no mouse actions are detected.
Could someone help me with how to either properly set SetCapture() or point me to where I might discover how to read mouse actions outside the dialog box? I'm happy to supply code, but at this point it's a bit of a mess since I've been trying everything.
Thanks for any help you may be able to provide. Much appreciated.
|
|
|
|

|
rbrunton wrote: I am trying to create a dialog MFC application that reads the cursor position anywhere on the screen, finds the colour of the pixel at that location and reports the information back to the dialog application. This sounds like Pixie. I've used it a few times, and it does what I needed it to do.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|

|
Thanks David,
I'll check it out as a tool, but I'm really looking to find out how to accomplish the task; essentially a programming learning experience.
|
|
|
|

|
PS - Pixie doesn't seem to address the key problem. Instead of using a left-mouse click to grab the colour at the particular location, pixie require keyboard shortcuts - Ctrl+Alt+c to copy HTML, Ctrl_Alt_X for to bring up the standard windows color dialog and Ctrl+Alt+Z to display a larger background of the color at the cursor. I would like to accomplish the selection with the left-mouse click as that seems a little more "natural" in a windows environment and then have the result in the main dialog screen of the application to manipulate it into various formats (HEX, RGB, HTML, etc.)
|
|
|
|

|
Take a look at windows hooks.
==============================
Nothing to say.
|
|
|
|

|
May be you just want to capture the mouse position, and you have no problem in finding the colour, then you can set a new Timer, then in the OnTimer function, you may try GetCursorPos() to retrieve the mouse's position.
If you want to capture other mouse's action like mouse click... then take a look at global hook, as described in this Mouse and KeyBoard Hooking utility with VC++[^]
|
|
|
|

|
I found if set TTF_TRACK flag to CTooltipCtrl, SetDelayTime doesn't work anymore, so the tooltip won't disappear automatically. I want to show the tooltip just below specified control, and expect it to disappear after a few seconds(the time can set with SetDelayTime). Anybody can help me?
Here is my steps to construct tool tip:1. Add member variable
CToolTipCtrl m_tooltip;
2. override PreTranslateMessage
BOOL CPF_GetSetNameDlg::PreTranslateMessage( MSG* pMsg )
{
switch (pMsg->message)
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
case WM_MOUSEMOVE:
m_tooltip.RelayEvent(pMsg);
break;
}
return CDialog::PreTranslateMessage(pMsg);
}
3. OnInitialDialog
BOOL CPF_GetSetNameDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//tooltip
EnableToolTips();
m_tooltip.Create(this , WS_POPUP | TTS_NOPREFIX | TTS_BALLOON);
m_tooltip.SetDelayTime(TTDT_INITIAL, 0);
m_tooltip.SetDelayTime(TTDT_AUTOPOP, 30000);
m_tooltip.SetDelayTime(TTDT_RESHOW, 30000);
m_tooltip.AddTool(GetDlgItem(IDC_SETNAME), _T(""));
m_tooltip.SetMaxTipWidth(600);
}
4. Control to show tool tip
if(bShow)
{
m_tooltip.UpdateTipText(_T("Hello, money!"), pWnd);
CToolInfo sTinfo;
m_tooltip.GetToolInfo(sTinfo, pWnd);
sTinfo.uFlags = TTF_TRACK;
m_tooltip.SetToolInfo(&sTinfo);
CRect rect;
pWnd->GetWindowRect(rect);
m_tooltip.SendMessage(TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(rect.left, rect.bottom));
m_tooltip.SendMessage(TTM_TRACKACTIVATE, TRUE, (LPARAM)&sTinfo );
}
|
|
|
|

|
I have this code:
if(m_Bitmap.GetSafeHandle())
m_Bitmap.DeleteObject();
HBITMAP hBitmap = (HBITMAP)::LoadImage(NULL, lpszPathName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
if(NULL == hBitmap)
{
CString sMessage;
const DWORD dwError = ::GetLastError();
sMessage.Format(_T("Failed to load '%s' file. Reason: %s\n"), lpszPathName, GetErrorString(dwError));
AfxMessageBox(sMessage, NULL, MB_ICONERROR);
return FALSE;
}
m_Bitmap.Attach(hBitmap);
and work ok, but on the big bitmaps, I get:
Not enough server storage is available to process this command
ok, I read this one[^], and I modified the "IRPStackSize" value to 0x19 (25 decimal), not working ... hoe can I get rid of this error ?
modified 12-Jun-13 4:37am.
|
|
|
|

|
Is it really that error message and not the code 8 ERROR_NOT_ENOUGH_MEMORY message 'Not enough storage is available to process this command'?
You might google for 'loadimage ERROR_NOT_ENOUGH_MEMORY'. Reading some of the results, it seems that removing the LR_CREATEDIBSECTION flag might solve the problem. If you need a DIBSECTION bitmap and loading the image as DDB succeeds, you might try the CopyImage()[^] function afterwards to convert the loaded DDB.
|
|
|
|

|
I had removed LR_CREATEDIBSECTION flag from LoadImage function, and I had the same error ... :(
|
|
|
|

|
How big is your image? If you read some of the Google results, you will find that others had similar problems and solved it by using other methods to load images from files (e.g. the MFC CImage class that uses Gdiplus::Bitmap). Check also if your image is valid by loading it with any painting program. Also check that the image is not RLE compressed.
|
|
|
|

|
I confes that the problem taking place at 750 MB bitmap file ... I agree, the picture is huge, but the Windows 7 netive viewer can open this bitmap ... Though, MSPaint (Paint windows native image editor) give the same result (even get the same error message), can not open this picture as well ...
modified 12-Jun-13 6:13am.
|
|
|
|

|
That is large; probably too large. There are system and OS depending limits for bitmaps (required memory and max. width and height). While loading the bitmap, twice the memory is required when it must be converted in some way.
It seems that the picture viewer uses some other method (e.g. allocating a buffer, reading the image line by line, converting each line to the pixel format used by the video card and finally copying the content from the buffer to the video memory).
|
|
|
|

|
Ok, you are very kind ! Kindly thank you for your interest !
|
|
|
|

|
Hello Friends
I am using SetupDigetRegistryProperty to access USB Devices.
So,regarding that I was trying to access Property SPDRP_LEGACYBUSTYPE which is described like this
Quote: SPDRP_LEGACYBUSTYPE
The function retrieves the device's legacy bus type as an INTERFACE_TYPE value (defined in Wdm.h and Ntddk.h).
I tried to get this value in char ,it returns some special character. I tried to catch in DWORD,it returns some number.
DWORD DataT;
LPTSTR buffer = NULL;
DWORD buffersize = 0;
SetupDiGetDeviceRegistryProperty(
hDevInfoSet,
&DeviceInfoData,
SPDRP_LEGACYBUSTYPE,
&DataT,
(PBYTE)buffer,
buffersize,
&buffersize)
Any Ideas?
Regards
Y
|
|
|
|
|

|
Thanks jochen for your Reply.
I tried ur way but it is not the value that I was looking For.
May be you can give more Ideas. here is what I want. When I right Click on USB Device from Device manager,it open up properties Dialog where we can select property and its value. Here, I found one property "bus relation" which I am trying to get using SetupDi calls.
Bus relation value is showing like this :
USBPRINT\CANONIP4200\6&19ACF&0&USB001
This is the device Instance Id.
But when I tried to get same using SetDiGetDeviceInstanceId,it gives me like
USB\VID_04A9&PID_10A2\C34BBD
How can I get USBPRINT\CANONIP4200\6&19ACF&0&USB001 ?
Regards
Y
|
|
|
|
|

|
Thanks A Lot jochen
I followed your post and get succeed in getting Bus Relation value[Device Id] which gives me Printer name.
Thank you Very Much Again.
Regards
Y
|
|
|
|

|
Nice to hear that you solved the problem and thank you for the feedback.
|
|
|
|

|
Hi,
I working on a plugin system for a MFC C++ application. So I started with a small plugin DLL with a simple function creating an object of a class with virtual functions and returning that object to the caller. The object is created on the heap and actually a pointer to the object is returned.
In the main application a function loads the plugin (LoadLibrary), searches the exported function (GetProcAddress) and executes the function. As result the created object is available, as expected. So far so good.
Btw: the class is already declared in a different DLL linked by both the main application and the plugin DLL.
Next I want to unload the plugin with FreeLibrary.
That leads to the problem of a corrupt vftable of the created object. I found out, that the __vfptr is in the memory of the plugin DLL and so unloading the DLL destroys that memory and the __vfptr is not usable anymore.
Is there any way to change that behaviour?
with kind regards,
Joerg
|
|
|
|

|
In a word: No. If the object is created from a DLL that was dynamically loaded, then you must not unload the library until all instances of the class have been deleted.
Use the best guess
|
|
|
|

|
If you unload the DLL then you remove all code from memory that represents the implementation of class methods including the actual vtable that points to these methods. Another important thing: the code that deletes the object should be in the DLL (same is true for object creation, normally you create an instance by calling an exported dll method)! One good solution to that is putting a Release() method into your class and Release() could simply do the "delete this;" stuff. Delete all class instances before unloading the DLL.
|
|
|
|

|
You could create a static function in the dll where the class is defined. This function would create the object inside the dll with parameters from the plugin. It returns the pointer to the plugin who passes it to the application. This way the object should be defined entirely in the dll so that you can unload the plugin.
However you should consider, whether it is really necessary to use the plugin unter these circumstances i.e. when the application knows the actual type of the returned object.
|
|
|
|

|
Creating webbrowser as below
hret=CoCreateInstance(clsid,NULL,CLSCTX_ALL,IID_IUnknown
,reinterpret_cast<void**>(&m_pUnknown));
hret=m_pUnknown->QueryInterface(IID_IWebBrowser2,(PVOID *)&m_pBrowser);
ASSERT(SUCCEEDED(hret));
but when i say
HRESULT hret = m_pBrowser->Navigate2(varURL,&noArg,&noArg,&noArg,&noArg);
its opening new IE window on WIn7. But in Xp sys its not happening like that. I dont want to open new IE window
Any one has any idea why it is opening on new IE window on Win7
|
|
|
|

|
It's quite possible (and not unknown) for later versions to contain stricter interpretation of optional parameters. The documentation[^] shows how to set the required behaviour.
Use the best guess
|
|
|
|

|
I tried a lot on this but couldn't able to resolve this
Can any one help?
|
|
|
|

|
Hi,
I am working on a project in which I use DirectShow to Play / Pause / Stop the video. I am using progress bar which increments along with the video. Now I want to use Slider bar instead of the progress bar which should increment along with the video. Also user should be able to control the video using slider (move forward / backward). I had used timers in which I am incrementing the progress bar.
How to use Sliders so that while video is playing, slider should increment along with the video showing the progress of the video.
Anybody have any idea or any sample code for the same.?
Regards,
Mbatra
|
|
|
|

|
Have you looked at the CSliderCtrl members? I'm seeing SetRange() and SetPos(), both of which look like they'd be part of the solution.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
modified 10-Jun-13 14:44pm.
|
|
|
|

|
Hi David,
Thanks for the reply.
These functions we can use to update the position of the slider. I
want to make the slider synchronize with the timer and the duration of the video. At any time when user drags the slider forward or backward, the playing video should also move forward or backward and timer value should also be changed.
You can say, I want the functionality similar to YouTube, playing a video and user can move forward or backward. Accordingly the video and the timer changes their values.
Do you have any sample code for the same.?
Regards,
Mbatra
|
|
|
|

|
That article I referenced you to earlier shows how to use the IMediaSeeking::SetPositions() method. You'll call this method when handling the TRBN_THUMBPOSCHANGING message.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|

|
mbatra31 wrote: You can say, I want the functionality similar to YouTube, playing a video and user can move forward or backward. Accordingly the video and the timer changes their values.
you can follow this logic
- get total video length in seconds
- create slider based on resulting time
- handle sliderctrl message http://msdn.microsoft.com/en-us/library/ekx9yz55(v=vs.80).aspx[^]
- move your video time line appropriately
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|

|
Hi,
I have followed the similar points. At point No.3, I want to forward the video in proportion to the slider value. But issue is how to get IMediaSeeking interface reference to the running video. So that I can set the position of the next seek frame.
Regards,
Mbatra
|
|
|
|

|
mbatra31 wrote: But issue is how to get IMediaSeeking interface reference... In that DirectShow example I referenced you to (several times now), look at the PlayerClass::Initialise() method. It shows how to get references to three different interfaces, IMediaSeeking included.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|

|
Hi.. I have implemented ECC algorithm in C++ and it is working fine with g++ compiler... I need to apply this program to network simulator - 3. Complier of NS-3 is "./waf", there it is not building and it is giving countless errors mainly regarding "ostream".
there is a line regarding ostream in my header function....---
// ostream handler
template<int T>
friend ostream& operator<<(ostream& os, const FiniteFieldElement<T>& g)
{
return os << g.i_;
}
|
|
|
|

|
Manoj7390 wrote: it is giving countless errors Without the detail of those errors no one can guess what is wrong.
Use the best guess
|
|
|
|

|
In the main program i am calling another header function called "FiniteFieldElement.h" function. In that function i have used --
// ostream handler
template<int T>
friend ostream& operator<<(ostream& os, const FiniteFieldElement<T>& g)
{
return os << g.i_;
}
I am calling this function and using "ostream" in so many places in main function. I am getting the errors like..
/usr/include/c++/4.6/ostream:493:5: note: template std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const _CharT*)
/usr/include/c++/4.6/ostream:473:5: note: template std::basic_ostream& std::operator<<(std::basic_ostream&, unsigned char)
/usr/include/c++/4.6/ostream:468:5: note: template std::basic_ostream& std::operator<<(std::basic_ostream&, signed char)
/usr/include/c++/4.6/ostream:462:5: note: template std::basic_ostream& std::operator<<(std::basic_ostream&, char)
/usr/include/c++/4.6/ostream:456:5: note: template std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char)
/usr/include/c++/4.6/ostream:451:5: note: template std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, _CharT)
|
|
|
|
|

|
I think it is not the problem with the code, because i am getting the output with g++ compiler. Now i am using ./waf compiler for NS-3, where i am facing problem. I am not sure ostream is supported by NS-3 because there they use NS_LOG_UNCOND("message") instead of "cout".
I am getting errors where i have used ostream. What do you mean by "ostream" and is it compiler dependent.
|
|
|
|

|
Manoj7390 wrote: What do you mean by "ostream" I don't mean anything by it, it is part of the standard C++ library. Also, I have no idea what ./waf compiler for NS-3 is, or what features it supports.
Use the best guess
|
|
|
|

|
Richard MacCutchan wrote: I have no idea what ./waf compiler
I suspect it is not even a compiler: waf[^].
Veni, vidi, vici.
|
|
|
|

|
No surprise there.
Use the best guess
|
|
|
|

|
Hi,
I have a application developed in VC++(MFC).Its a MDI application.I am very new to Unit testing. So i need to use a Unit testing framework\tool for it's unit testing.
Kindly any one please suggest any Unti testing tool and also if you have any demo of that suggested Tool's implementation for MFC code, Then it will be easier to catch easier . If that testing tool is a Free like GoogleTest(gtest) then it'll be more prefarable.
I searched a lot, but i didn't get idea as per my requirement(exspecially for MFC code unittesting).So need help.Please suggest.
Thanks
|
|
|
|
|
|

|
pk jain wrote: In future if i get any more docmunets related to MFC untitestng i'll update here. Again hoping the same from you too.
better write a small tip and post it on CP. your message may lost here!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|

|
Hi
I am getting the above mentioned error in all my .cpp files I don't see any where I am using DAO classes
maybe they are some how included in stdafx,h yes I am compiling as 64 bit code
Thanks
|
|
|
|
 |