|
|
You might want to look into Browser Helper Objects.
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
Hi All,
I'm trying to find a way to add a menu item to the context menu of highlighted text in windows. Is this possible? Ideally, it would be for any application that you could highlight text in.
Thanks,
Neil
|
|
|
|
|
Hi,
Please, using Crypto++, let me know how to get d, e and n numbers. I need them
I guess they are into RSAES_OAEP_SHA_Decryptor structure but any help will be great for me
Thank you VERY much !
Florian
|
|
|
|
|
RSAES_OAEP_SHA_Decryptor is derived from InvertibleRSAFunction which is derived from RSAFunction, so if you have a RSAES_OAEP_SHA_Decryptor object you can use this
<br />
RSAES_OAEP_SHA_Decryptor dec(... parameters go here ...);<br />
Integer d = dec.GetDecryptionExponent();<br />
Integer e = dec.GetExponent();<br />
Integer n = dec.GetModulus();<br />
|
|
|
|
|
Yeah ! Thank you very very much, that's great
Cheers,
Florian
|
|
|
|
|
Hi,
You are right about classes derivations and these functions exist, but when I try to use them here is what I get :
error C2039: 'GetModulus' : is not a member of 'RSAPrivateKeyTemplate<class cryptopp::decryptortemplate<class="" cryptopp::oaep<class="" cryptopp::sha,class="" cryptopp
::p1363_mgf1<class="" cryptopp::sha="">,&unsigned char * CryptoPP::OAEP_P_DEFAULT,0>,class CryptoPP::InvertibleRSAFunction> >'
Any idea ?
Thanks !
|
|
|
|
|
I'm trying to do multithreading in a Win32 C++ ( DirectX ) game. I've been having this compile error:
*******
error C2440: 'type cast' cannot convert from 'overloaded-function' to 'LPTHREAD_START_ROUTINE'
********
Now here's the question. I have two versions, a long version and short version, in case anyone can answer the short version so that you dont need to read the long version.
*** Short question:
Can you pass a class function through the 3rd argument of CreateThread?
*** Long question:
Here's a small example code of what I'm trying to do:
////////////////////////////////////////////////////
// MAIN.H
////////////////////////////////////////////////////
#pragma once
class CMyClass
{
private:
HANDLE m_hThread;
DWORD m_ThreadID;
public:
void FunctionToCallThread( void );
DWORD WINAPI Thread( DWORD );
};
//////////////////////////////////////////////////////
// MAIN.CPP
//////////////////////////////////////////////////////
#include <stdio.h>
#include <windows.h>
#include "Main.h"
void main( void )
{
CMyClass MyClass;
MyClass.FunctionToCallThread( );
}
void CMyClass::FunctionToCallThread( void )
{
m_hThread = CreateThread( NULL, 0, ( LPTHREAD_START_ROUTINE )Thread, 0, 0, &m_ThreadID );
printf( "Starting\n" );
Sleep( 1000 );
for( int i = 0; i < 50; i++ )
{
printf("u\n");
Sleep( 1000 );
}
}
DWORD WINAPI CMyClass::Thread( DWORD data )
{
for( int i = 0; i < 50; i++ )
{
printf("hi\n");
Sleep( 1000 );
}
CloseHandle( hThread );
return data;
}
//////////////////////////////////////////////////
// end code
//////////////////////////////////////////////////
So here's what's the program does:
1) Create a class from CMyClass called MyClass
2) Call MyClass.FunctionToCallThread( )
3) MyClass.FunctionToCallThread starts a thread from the function MyClass.Thread( DWORD ) (or it should anyway). Then prints 'u\n' every second 50 times
4) The thread should then print 'hi\n' every second 50 times then closes itself.
.................................................
I've been looking on the net for the past 3 hours why this wouldn't work. on MSDN, Google, and even articles on here. I'd appreicate if any of you could help me with this And thanks in advance.
Doug
|
|
|
|
|
First, you should be using _beginthreadex() since you are using the CRT.
You also need to pass a "static" function address to _beginthreadex() and, in this situation, pass this as the argument to the newly created thread. Inside the thread function, using the pointer to the class to call the classes "Thread" routine.
A code snippet for my thread base class:
This is from the .h file (heavily stripped down. If it isn't already obvious, you derive a new class from CBThread and provide a ThreadMain() member function.):
typedef unsigned (__stdcall *PCBTHREAD_FUNCTION)(void *);
class CBThread : public CBHandle
{
public:
virtual unsigned ThreadMain() = 0;
public:
CBThread() {}
BOOL Create(
PCBTHREAD_FUNCTION pThread,
LPVOID pParam = NULL,
unsigned stackSize = 0,
BOOL startSuspended = FALSE,
int priority = -1);
BOOL Create(
unsigned stackSize = 0,
BOOL startSuspended = FALSE,
int priority = -1);
};
This is from the .cpp file:
static unsigned __stdcall CBThreadThread(CBThread *pClass)
{
return pClass->ThreadMain();
}
BOOL CBThread::Create(
PCBTHREAD_FUNCTION pThread,
LPVOID pParam,
unsigned stackSize,
BOOL startSuspended,
int priority)
{
if (IsRunning())
return FALSE;
unsigned threadID;
if ((m_handle = (HANDLE) _beginthreadex(NULL, stackSize, pThread, pParam, startSuspended, &threadID)) != NULL)
{
if (priority >= 0)
SetPriority(priority);
return TRUE;
}
return FALSE;
}
BOOL CBThread::Create(
unsigned stackSize,
BOOL startSuspended,
int priority)
{
return Create((PCBTHREAD_FUNCTION)CBThreadThread, this, stackSize, startSuspended, priority);
}
|
|
|
|
|
Dear Friends
I wish to place a bitmap file as a button on a full screen video display.
but i can`t able to get the handle of the full screen window for displaying it by BitBlt function.
So kindly give a solution.
Thanksing You.
With Regards,
Friend
|
|
|
|
|
Im new,ish, to MFC and was hoping one of you knowledgable folks be kindenough to show me how to convert the t_time values of leaseobtained/expires, so i can display them in a static control. And does anyone know the whereabouts of a practical example of IpRenew/releaseAddress, i cant seem to get it to work proberly :/
Thanks in advance
|
|
|
|
|
I wrote a demo project for demonstrates the problem. Maby the project file is bigger than the permit post in the forum .IF you would like,I will E-mail the demo to you!My E-mail:wmc0860@sina.com
There is a problem.I debugger it many times,I knew the problem produce in the Function -void CTestDlg::OnChooseOriI(UINT nID) .but has no good methods to solved it.Maybe some VC++ specialist can find the pivotal reason.Can you help me ?If required the the CMyButton Class,PLS tell me!
The scene is follows://see the Attachment
Scene1:
Scene2:
Scene3:
Scene4:
my purpose is if switch the destination and the follow source signal status can be load.
and select source signal button interlock!
So far the destination select can be interlock,and the source select can be interlock!
but if I choose previously destination button ,this destionation load the source button
status is my have selected the source status all,not is my want is the latest select .but if
I select the source button again,it can be interlock.
For saving source select button status,In codes ,I create a *.ini file ,and make the source button
status worte in the *.ini file! each select the destination button ,can read the source button status
form the *.ini file.
see my follows code(one part )
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
.....
iniFile.Open("testDlgconfig.ini" ,CFile::modeCreate|CFile::modeNoTruncate|CFile::mo
deReadWrite|CFile::shareDenyWrite);
m_pAr=new CArchive(&iniFile,CArchive::load);//create the ini file pointer
if(iniFile.GetLength()!=0)
{
//read the status from the ini file!
for(int i=0;i<4;i++)
for(int j=0;j<16;j++)
{
(*m_pAr)>>m_byStatus[i][j];//BYTE m_byStatus[4][16],the array variable saved the source button select status
}
}
//read finish,destroy the pointer
m_pAr->Close();
delete m_pAr;
}
//Define the destination and source button select event
BOOL CTestDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
UINT nID=LOWORD(wParam);
HWND hWndCtrl=(HWND)lParam;
int nCode=HIWORD(wParam);
//
if((nID>=IDC_CHOOSEDES1)&&(nID<=IDC_CHOOSEDES4))
{
if(nCode==BN_CLICKED)
{
OnChooseDesI(nID-IDC_CHOOSEDES1);
}
}
if((nID>=IDC_CHOOSEORI1)&&(nID<=IDC_CHOOSEORI16))
{
if(nCode==BN_CLICKED)
OnChooseOriI(nID);
}
return CDialog::OnCommand(wParam, lParam);
}
//destination button select function,nSel parameter is the what destination button select!
void CTestDlg::OnChooseDesI(int nSel)
{
for(int i=0;i<4;i++)
{
if(i==nSel)
{
m_buChooseDes[i].m_nFlag=1;//m_nFlag =1,means the button be pressed status;m_buChooseDes[4],is the object array of the class CMyButton .
m_buChooseDes[i].RedrawWindow();
for(int j=0;j<16;j++)
{
m_buChooseOri[j].m_nFlag=m_byStatus[i][j];//m_buChooseOri[16],is the object array of the class CMyButton.
m_buChooseOri[j].RedrawWindow();
}
continue;
}
if(m_buChooseDes[i].m_nFlag==1)
{
m_buChooseDes[i].m_nFlag=0;
m_buChooseDes[i].RedrawWindow();
}
}
}
// select the source button ,the nID parameter means the button's ID what soucre button selected
void CTestDlg::OnChooseOriI(UINT nID)
{
//find the destination selected button nSel
int nSel;
for(int i=0;i<4;i++)
{
if(m_buChooseDes[i].m_nFlag==1)
{
nSel=i;
break;
}
}
if(i==4) return;
//select source button select function implement
int m=nID-IDC_CHOOSEORI1;
for(int j=0;j<16;j++)
{
if(j==m)
{
m_buChooseOri[j].m_nFlag=1;
m_buChooseOri[j].RedrawWindow();
continue;
}
if(m_buChooseOri[j].m_nFlag==1)
{
m_buChooseOri[j].m_nFlag=0;
m_buChooseOri[j].RedrawWindow();
}
}
// save the source select button status
m_byStatus[nSel][nID-IDC_CHOOSEORI1]=m_buChooseOri[nID-IDC_CHOOSEORI1].m_nFlag;
m_buChooseOri[nID-IDC_CHOOSEORI1].RedrawWindow();
}
|
|
|
|
|
bit OADM_Disconnect(void)
{
bit bDropOADS=0, bAddOADS=0;
int i=0, iPortValue=0, iPorts=pMsg[0], j=0;
//sbit SetBit=0;
//if(iPorts>PORT_SWITCH_MAX) return;
if(iPorts>PORT_SWITCH_MAX) return false; //every call can only set up to 8 ports/mirrors
for(i=0; i<iports; i++)=""
="" {
="" iportvalue="pMsg[i+1];
" if(iportvalue="">0 && iPortValue<9)
{
j=iPortValue-1;
if (j==0)
{SetBit10=pCardStatus[STATUS_DROP_BYTE]^0; SetBit10=0;}
if (j==1)
{SetBit11=pCardStatus[STATUS_DROP_BYTE]^1; SetBit11=0;}
if (j==2)
{SetBit12=pCardStatus[STATUS_DROP_BYTE]^2; SetBit12=0;}
if (j==3)
{SetBit13=pCardStatus[STATUS_DROP_BYTE]^3; SetBit13=0;}
if (j==4)
{SetBit14=pCardStatus[STATUS_DROP_BYTE]^4; SetBit14=0;}
if (j==5)
{SetBit15=pCardStatus[STATUS_DROP_BYTE]^5; SetBit15=0;}
if (j==6)
{SetBit16=pCardStatus[STATUS_DROP_BYTE]^6; SetBit16=0;}
if (j==7)
{SetBit17=pCardStatus[STATUS_DROP_BYTE]^7; SetBit17=0;}
//SetBit=pCardStatus[STATUS_DROP_BYTE]^(iPortValue-1);
//SetBit=0;
bDropOADS=true;
}
else
{
if(iPortValue>64 && iPortValue<73)
{
j=iPortValue-65;//was -57-1=-58
if (j==7)
{SetBit00=pCardStatus[STATUS_ADD_BYTE]^0; SetBit00=0;} // start with bit 8
if (j==6)
{SetBit01=pCardStatus[STATUS_ADD_BYTE]^1; SetBit01=0;}
if (j==5)
{SetBit02=pCardStatus[STATUS_ADD_BYTE]^2; SetBit02=0;}
if (j==4)
{SetBit03=pCardStatus[STATUS_ADD_BYTE]^3; SetBit03=0;}
if (j==3)
{SetBit04=pCardStatus[STATUS_ADD_BYTE]^4; SetBit04=0;}
if (j==2)
{SetBit05=pCardStatus[STATUS_ADD_BYTE]^5; SetBit05=0;}
if (j==1)
{SetBit06=pCardStatus[STATUS_ADD_BYTE]^6; SetBit06=0;}
if (j==0)
{SetBit07=pCardStatus[STATUS_ADD_BYTE]^7; SetBit07=0;}
//SetBit=pCardStatus[STATUS_ADD_BYTE]^(iPortValue-58); // start with bit 8
//SetBit=0;
bAddOADS=true;
}
}
}
// determine which hardware function to call
if(bDropOADS)
{
DROP_CHAN = pCardStatus[STATUS_DROP_BYTE];
DROP_OADS();
//////////testing//////////////
ACC='K';
TX_BYTE();
ACC='K';
TX_BYTE();
ACC=DROP_CHAN;
TX_BYTE();
ACC='K';
TX_BYTE();
ACC='K';
TX_BYTE();
/////////////////////////////////
}
if(bAddOADS)
{
ADD_CHAN = pCardStatus[STATUS_ADD_BYTE];
ADD_OADS();
//////////testing//////////////
ACC='K';
TX_BYTE();
ACC='K';
TX_BYTE();
ACC=ADD_CHAN;
TX_BYTE();
ACC='K';
TX_BYTE();
ACC='K';
TX_BYTE();
/////////////////////////////////
}
OADM_ReportStatus(false);
INIT_I2C();
return true; //added
}
I was given the above the code, but don't really understand how the function behave and how it works. This code is used to control a device hardware. The SWITCH_MAX is defined as 8.Can somebody advise me? Thank you very much.
|
|
|
|
|
...let two or more users connect (one being a server?) and have the users draw on the same canvas (possibly w/ a specified background picture)
kind of like a collective drawing (one person draws a line, everyone else sees it)
i made a program like this but it's crap.. so i wanted to know if there was a popular free utility that could do that
thanks
Roman Nurik
|
|
|
|
|
|
take a look at this link: http://www.realvnc.com/[^] you'll find a program that is used to monitor and control other PC's like Symantec's PC Anywhere, the good point is that you can find the sourcecodes there as it is opensource, and that you could do this app by yourself...
Hope this helps...
|
|
|
|
|
I have MFC MDI app with number of child windows all "maximized", i.e. (max when activated) ....
When single window is "restored" MDI shows rest of the windows in "restored" state....
Is there any way to alter framework to allow restored child displayed over maximized window?
Thanks,
Brian
|
|
|
|
|
It looks like Opera does just that.... Is opera MDI app?
|
|
|
|
|
I would like to write an application, having MANY classes. Each class needs access to a common (application-wide) global variable, say, int nVAR.
One of the classes would "set" nVAR, the rest of the classes would "get" nVAR.
Could someone please provide a simple sample code showing how to do this (or provide references to applicable samples).
Also, according to several sources I read "global variables" should NOT be used. Then WHAT should be used?
|
|
|
|
|
look for the singleton pattern, it's a class that can be instanciated only once, and can live everywhere,
for example ( taken from Design Patter, by Gamma, Helm, Johnson and Vlissides):
class Singleton {
public:
static Singleton* Instance();
protected:
Singleton();
private:
static Singleton* _instance;
};
The corresponding implementation is
Singleton* Singleton::_instance = 0;
Singleton* Singleton::Instance () {
if (_instance == 0) {
_instance = new Singleton;
}
return _instance;
}
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
There are no iron-cast, inviolable laws of programming.
Every program usually has at least a few things that are global and creating global variables for them is fine. It's the excessive, unnecessary use of global variables that causes problems.
Using a Singleton class is fine in itself but you want to be careful not to put a whole lot of stuff in place that ends up with you having a really complicated global variable
The situation you describe is a good case for *not* using a global variable since it introduces a coupling between your classes that can be hard to detect. Better if you make it a static member variable of the setting class and provide a static "get" method. That way, the coupling is obvious.
Software is everything. It also sucks. Charles Fishman [^]
Awasu 1.0.3 (beta)[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Gabor Kalman wrote:
Then WHAT should be used?
Static variables inside a class visible to everywhere, or inside a namespace, or globals in an unnamed namespace. Anything else is a nightmare, although obviously one global is not going to bring your project to your knees, I usually regard a long list of glabals as evidence that people have elsewhere used bad practices out of ignorance or laziness. It's better to do things right ALL the time than to make allowances where you can't be bothered.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Hi there,
I just finished compiling a static library with Dev-C++ 5.0. I tried to use the library in VC++ 6.0, but this brings up the error LNK1136 while trying to link...How can I get that to work? Does anybody have an idea? Is there a free compiler which can be used to produce static libraries that are compatible to VC++ 6.0 ??
thanks in advance...
jason
|
|
|
|
|
I experienced the most bizzare thing with SetPaneText
Some application of mine has a CStatusBar with 3 panes.
It's created properly, and SetPaneText() calls are successful for pane 1, but not for pane 2.
My indicators were declared as follows :
static UINT indicators[] =
{
ID_SEPARATOR,
ID_PANE1,
ID_PANE2
}
If I swap positions of ID_PANE1 and ID_PANE2 in indicators declaration, then SetPaneText works for pane 2, but not 1.
So I checked the declaration of ID_PANE1 and ID_PANE2 in the resource header file. Nothing unsual, besides ID_PANE1 shows up as hexadecimal when all other strings are decimal.
Deleting ID_PANE2 and re-inserting it from the string resources did the trick. But I'm still confused about why a simple string declaration has been able to block SetPaneText.
JC
|
|
|
|
|
Ok, I have a class called CComboBox2. Lets assume there's not much to it other than the declaration. It is derived from CComboBox(public)
I put the CComboBox2 in my afx message map.
Windows is not dunningmy dialog-level handler.
It does call the class's own OnSelchange():
void CComboBox2::OnSelchange()
{
m_bChanged = true;
CEdit2::SetChange(true);
}
It is used on a dialog where a CMyDialog::OnSelchangeCombo1() is defined.
What must I do to get the dialog's OnSelchangeCombo1() to run?
Many thanks in advance!
|
|
|
|
|