|
Is there a simple way to set the background color of a CView ?
|
|
|
|
|
Override CYourView::OnEraseBkgnd(CDC *pDC) and fill the client area with desired color/pattern there. Return TRUE - do not call the base implementation.
There are many ways to reach this, some other could be better for your specific needs (unless you derive from CView only to draw the background ).
Regards,
BB
|
|
|
|
|
Hi all,
does anyone know hot to be notified if a .exe file start running? I both need it for regular applications and services, too, but I think the solution could be the same. Basically I would need of a signaled event when the monitored .exe is start running for app. I would also need a signaled event when some changes happen in the services controlled by the Service Control Manager.
Thanx in advance.
Regards,
Andrea
|
|
|
|
|
There are a lot of methods to do this...
here two of them (possibly not the best of them, but the ones I know )
1.
You can use findwindow in time intervals in order to know if your app is there, this is an easy trick, but it can be a problem if your app hungs.
2.
your app can lock a dummy file and the others can monitor that file state, if it is locked your app is running...
Hope this helps.
|
|
|
|
|
Hi Joan,
unfortunately these solutions have a counterpart: they need CPU time for testing!
I need something more efficient...
Regards,
Andrea
|
|
|
|
|
yes, of course those solutions need CPU, but how do you want to be sure that the app is going on without looking for it often?
Imagine that you send a message from your app to the "controller" (I'll call controller to the application that needs to know if your app is active) when your app starts, and another when your app stops...
If you can ensure that your app won't hung and that the controller is started before the app, this could be a good solution, think about a button (or something similar in your controller in order to kill the flag (only in case that your app hungs)).
Remember not to use FindWindow (if your app can hung, this could make the controller hung also).
Think about:
what could happen if your controller was not started before the app?
For this reason I thought on the file locking method... (that sacrifices some CPU making the controller looking after that, but gives you almost all the control needed.
I've used that in order to make two controlling services to know about if my app was running, if my app, or one of the services was stopped the computer immediately stopped... (this was done in a console computer environment (a computer programmed to move a machine)).
If you don't need to know about the state of your app. you can use the sending of messages, cheap and easy.
Think about a messages protocol that allow the two apps to communicate...
hope this helps...
|
|
|
|
|
I have posted this question before a long time ago and nobody gave me an answer, but I kind of came up with a solution. However, the problem surfaced again. Here it goes.
I am using MSHFlexGrid to create tables and the user is allowed to delete rows from the table. The function that I use for that is RemoveItem. If the user wants to add a new row I call AddItem. However, after a call to RemoveItem, the next call to AddItem will not show the row on the control. The row is there (after AddItem) because when I write data on its cells, I get no errors. Another call to AddItem and voila, I have an empty new row on the table. This doesn't seem to work in the all the cases. Has anyone ever dealt with this problem before?
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Hi, i new to visual c++, and was required to make a project that can...
1) capture the navigation when user surf the net (maybe into a database?)
2) then i can view what web site has being navigate. (sounded like a history folder).
I surf a lot of web site trying to get any info for this but can't find any.
Then i read up that using ChtmlView can work like IE, which may solve my problems, but then i was wondering how can CHtmlView capture the navigation into a database so that i can view it later?
In need of help here. Any ideas?
I'm a newbie to visual c++, simpler terms please.
|
|
|
|
|
|
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
|
|
|
|
|