|
maybe it is some helpful to you
http://www.codeproject.com/dialog/skinedcaptionbars.asp
|
|
|
|
|
After repeated database operations while opening closing a child window of a dialog applications, a message box will pop up saying "Too many client tasks. Driver's SQLSetConnectAttr failed". I am a beginner in mfc/C++ programming and need this program runnning ASAP and any help would be appreciated. thanx
|
|
|
|
|
For every connection that you create, there must be a matching destroy. Why not just create one connection when the application is started, and destroy it when the application closes? Creating a connection to a datasource can be a very costly operation.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
The code given below works fine as long the mouse is on the application dialog,
but as it leaves the dialog mouse position coordinates do not change.
I have set hook as under;
pfnMyMouseMonitor = (HOOKPROC)MouseProc;
hMouseHook = ::SetWindowsHookEx(WH_MOUSE,pfnMyMouseMonitor,(HINSTANCE) NULL, GetCurrentThreadId());
Mouse function is as under
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
MOUSEHOOKSTRUCT* pms = (MOUSEHOOKSTRUCT*)lParam;
//pms->
if (nCode == HC_ACTION)
{
str.Format("x = %d : y = %d",pms->pt.x ,pms->pt.y);
px->SetWindowText(str); // px is pointer to static control on dialog
}
return(::CallNextHookEx(hMouseHook, nCode, wParam, lParam));
}
I donot want to use dlls.
Thanks in advance.
|
|
|
|
|
u can't put a globel mouse hook unless u put the hook function in a dll.
In this case in order to get the window text below, use
SetCapture()
nave
|
|
|
|
|
The system function call waveInGetPosition retrieves the current input position of the given waveform-audio input device. The function call returns the position in the parameter MMTIME in the given format. (if possible)
In my application I use the TIME_SAMPLES format wich specifies the current position in an offset in samples since the last time the waveform-audio input device was reset.
My question is: What would happen if a recording gets to long (nSamples>(2^32)-1).
I think it just simply wraps around the current position but I am not sure about this. (I have never tried) And it would take me about 12 hours to figure out by myself. (4294967296/96000/3600=12.43)
Thanks.
|
|
|
|
|
Hai to all,
Can anybody understand this function can you please explain me. by using this function the size of the image we are storing is increasing the size. I have to reduce that size. I am unable to find what to do. with out using this function the size of the image is 40kb and after using this function it size become 622kb. I am using Black and while image. I think by reading any image by Gdiplus Image function it will take it into color mode. becoz of that it is taking large size.
If possible can tell me how to reduce the size of the image.
CLogEntry CDocImage::MergeSignRegions(LPCTSTR szSaveFileName, FocusSide nSide ) {
CLogEntry retcode;
CString csError ;
Bitmap *pbmBase = NULL ;
Gdiplus::Image *pImageIn = NULL ;
Status saveStatus ;
// Don't do anything if there is no sign regions for this side.
if ((nSide == Side1 && m_ptaSignRegions.GetSize() == 0) ||
(nSide == Side2 && m_ptaSignRegions2.GetSize() == 0))
return retcode;
TCHAR szTempPath[MAX_PATH] = "\0";
TCHAR szSigTempFile[MAX_PATH] = "\0";
TCHAR szBaseTempFile[MAX_PATH] = "\0";
if ( !::GetTempPath( MAX_PATH, szTempPath ) ) {
VXTRACE();
return CLogEntry("Failed to get temp path.", -1);
}
// Get the number of sign regions of this side
int nSignRegionCount = 0;
if (nSide == Side1)
nSignRegionCount = m_ptaSignRegions.GetSize();
else
nSignRegionCount = m_ptaSignRegions2.GetSize();
// Load the saved document image and merge all signatures
try {
CLSID encoderClsid ;
WCHAR wcFileName[_MAX_PATH*sizeof(WCHAR)] ;
WCHAR wcTempName[_MAX_PATH*sizeof(WCHAR)] ;
WCHAR wcSaveName[_MAX_PATH*sizeof(WCHAR)] ;
LPCTSTR pszFileName ;
CDC memDC, sigDC ; // memory DC into which main image will be loaded
HBITMAP hbm, hbmSig ;
memDC.CreateCompatibleDC( CDC::FromHandle( ::GetDC( NULL ) ) ) ; // .like display.
sigDC.CreateCompatibleDC( CDC::FromHandle( ::GetDC( NULL ) ) ) ; // .like display.
if ( nSide == Side1 )
pszFileName = m_szFilename ;
else
pszFileName = m_szFilename2 ;
//--- Read in document image, as a tif
mbstowcs( wcFileName, pszFileName, sizeof( wcFileName ) ) ;
pImageIn = new Gdiplus::Image( wcFileName, false ) ;
if (!::GetTempFileName(szTempPath, "BAS", 0, szBaseTempFile)) {
VXTRACE() ;
return CLogEntry( _T("Failed to get base temp path"), -1 ) ;
}
// Get the CLSID of the BMP encoder
if ( GetEncoderClsid( L"image/tiff" /*L"image/bmp"*/, &encoderClsid ) == -1 ) {
::DeleteFile( szBaseTempFile ) ;
VXTRACE() ;
return CLogEntry( _T("Cannot find encoder clsid for BMP encoder"), -1 ) ;
}
//--- Save the document image as a bmp
mbstowcs( wcFileName, szBaseTempFile, sizeof( wcFileName ) ) ;
pImageIn->Save( wcFileName, &encoderClsid, NULL ) ;
//--- Reload document as a GDI+ BMP Image
pbmBase = new Bitmap( wcFileName, false ) ;
PixelFormat pxfBase = pbmBase->GetPixelFormat() ;
//--- Put base document bitmap into memory dc
Status status = pbmBase->GetHBITMAP( NULL, &hbm ) ;
memDC.SelectObject( hbm ) ;
CDC adc ; // memory DC for result
CBitmap bmp ; // will contain the composite image
bmp.CreateCompatibleBitmap( &memDC, pbmBase->GetWidth(), pbmBase->GetHeight() ) ;
adc.CreateCompatibleDC( &memDC ) ;
adc.SelectObject( bmp.m_hObject ) ;
//--- Suck the composite image out of the assembly dc, into a bmp that we can use
adc.BitBlt( 0, 0, pbmBase->GetWidth(), pbmBase->GetHeight(), &memDC, 0, 0, SRCCOPY ) ;
CPalette *pPal = memDC.GetCurrentPalette() ;
Bitmap *pSigMap = new Bitmap( (HBITMAP)bmp.m_hObject, (HPALETTE) pPal->m_hObject ) ;
if ( GetEncoderClsid( L"image/tiff", &encoderClsid ) == -1 ) {
VXTRACE() ;
return CLogEntry( _T("Cannot find encoder clsid for tiff encoder"), -1 ) ;
}
//--- Create a 2-parameter array, for Compression and for Color Bit depth
EncoderParameters* pEncoderParameters = (EncoderParameters*) malloc(sizeof(EncoderParameters)
+ 1 * sizeof(EncoderParameter));
//--- Use LZW Compression instead of Group 4, since it works for color and G4 doesn't
ULONG ulCompression = EncoderValueCompressionLZW ;
//--- 24-bit seems to be the SMALLEST one that works here - it might be the image, since
//--- the encoder claims to work for smaller values, but disk space is cheep.
ULONG ulColorDepth = 24L ;
pEncoderParameters->Count = 2 ;
pEncoderParameters->Parameter[0].NumberOfValues = 1 ;
pEncoderParameters->Parameter[0].Guid = EncoderCompression ;
pEncoderParameters->Parameter[0].Type = EncoderParameterValueTypeLong ;
pEncoderParameters->Parameter[0].Value = &ulCompression ;
pEncoderParameters->Parameter[1].NumberOfValues = 1 ;
pEncoderParameters->Parameter[1].Guid = EncoderColorDepth ;
pEncoderParameters->Parameter[1].Type = EncoderParameterValueTypeLong ;
pEncoderParameters->Parameter[1].Value = &ulColorDepth ;
mbstowcs( wcSaveName, szSaveFileName, sizeof( wcSaveName ) ) ;
saveStatus = pSigMap->Save( wcSaveName, &encoderClsid, pEncoderParameters ) ;
if ( saveStatus != Ok ) {
VXTRACE() ;
csError.Format( _T("Bitmap::Save failed for %s, error %d"), szSaveFileName, saveStatus ) ;
return CLogEntry( csError, -1 ) ;
}
} catch ( Exception error ) {
csError.Format( _T("ImageMagick Exception: %s"), error.what() ) ;
retcode = CLogEntry( csError, -1 ) ;
}
//--- can't delete the temporary file used for the Bitmap object while that object still exists
if ( pbmBase )
delete pbmBase ;
if ( pImageIn )
delete pImageIn ;
if ( *szBaseTempFile ) {
if ( !::DeleteFile( szBaseTempFile ) ) {
csError.Format( _T("DeleteFile failed for %s, error %d"), szSigTempFile, ::GetLastError() ) ;
return CLogEntry( csError, -1 ) ;
}
}
VETRACE();
return retcode ;
}
|
|
|
|
|
Every DHCP network has a DHCP server, and every DHCP server has a lease table. Every DHCP Lease table has a correlation of Mac to IP. I want to be able to access the information in the DHCP Lease Table without shutting down services. The Microsoft DHCP management console can do this, and the W2K3 admin pack (installed on a client computer) allows this to happen from a remote computer, so I know it can be done. Not all DHCP servers are Windows machines, some are Routers, some are Linux, etc. So is there a way of accessing the information in the Lease table regardless if it is on a Windows server, router, etc.? Could perhaps output the information to a .csv file in a temp folder for input/review for our program.
|
|
|
|
|
hi friends,
I connect to any website via proxy. But I want to connect to site by bypassing proxy.
for connecting proxy use
INTERNET_OPEN_TYPE_PRECONFIG
from CInternetsession class
I want to connect it without using proxy. kindly give me a reply.
Regards
kedar
Girish
Software Developer
|
|
|
|
|
Hello,
I have a LogIn Form which should close and destroy itself upon verification of password and username.
How can I link the text inputed to be verified from an Access file?.
Also,I want the logIn form to be closed and load a diferent Form (Not CDialog form). Any help is highly appreciated. Tks
new to Visual C++, bt we gonna make it catch-a-fi-er
|
|
|
|
|
Hi Gurus,
I have an ActiveX control that has an Edit control inside. I have embeded this control in IE. the problem is when i try to delete some text in Edit control using backspace key the browser takes me to the previous page instead of Erasing the text in Edit control. Does any one know how to deal with this situation
please its urgent
thanks
Muhammad Azam
|
|
|
|
|
I think it is because the browser gets the events first.
Subclass the Edit control, and you are good to go.
this is this.
|
|
|
|
|
Khan,
could you please ellaborate your point. I am not able to get it.
My ActiveX control contains other controls along with the Edit control.
AZam
|
|
|
|
|
I meant that you could subclass it. Which basically means implementing the WndProc for the control.
The actual code would depend on whether you are using MFC or not. In MFC, it is really easy, as you could just derive a class from CEdit. Then in that class, you can control everything the edit control does, like, handling backspace, Esc etc. In WTL, it is just a little different.
Search this site for the many edit controls:
http://www.codeproject.com/editctrl/[^]
Here, you will find many implementations. Choose the best one for your purpose.
this is this.
|
|
|
|
|
hi,
I need to open an text file to save the output data from the machine, i could open the text file and could write the output data to the text file, but the problem is how could i save the previous test data output if i again run the program?
file = fopen("output.txt", "w+");
...
fputs(txt, file);
fputs("\n", file);
If i run the program, i could write the data of the present running data output, i need to save the old output data for the checking the drift?
Can i use rewind????
Thnaks in advance
|
|
|
|
|
use file = fopen("output.txt", "a+"); to append, see function description in MSDN.
Regards
Ray
"Je Suis Mort De Rire"
Blogging @ Keratoconus Watch
|
|
|
|
|
Open the file for append, "a(+)" instead of "w+".
"w+" always creates the file.
"a" creates the file if it doesn't exist. Else, it adds to at the (previous) end of the file.
|
|
|
|
|
ya thankyou, it is working!!
Its appending from the end of the previous data file, like
1 // 1 2 3 4 .......one data output
2
3
4
5 //5 6 7 8.....another data output
6
7
8
if i would like to have as,
1
2
3
4 //as first data output
nad the next file output should begin in new line as
1 5
2 6
3 7
4 8..
hwo could i proceed??i would like tos tart in new line again
|
|
|
|
|
You mean a new column.
Well, that's not easy to do. Considder the data in the file (from the first run).
It's something like this:
1<new line="">
2<new line="">
3<new line="">
4<new line="">
Now you want to insert characters (" 5") in the first line, after "1" and before the <newline> character.
To be able to do that (in the simplest way), you will have to create a new file.
Then read from the old file, one line at the time, modify that line and then write the modified line to the new file.
When the new file is done, delete the old file and rename the new file to the old files name.
Not very easy for a beginner. Can you considder another principle?
|
|
|
|
|
Helo Mr. Kakan,
Is it possible to do so
1 2 3 4
5 6 7 8
writing the new data in another next line???
|
|
|
|
|
Hello chaitanya.
That's much easier. That way, you just append to the file.
Just make sure you put a '\n' character ONLY at the end of line.
Today, you write a '\n' for each value, which gives a newline after each value. That's the reason why you get each value on a separate text line in the file.
I don't know what function you are using for writing to the file today, but i suspect you are using fputc() or fputs(), right?
There are numerous ways to write to a file, this is just one way.
You can to this, using fputc. (I assume FILE * file):
int number = '1';
fputc(number, file);
fputc((int) ' ', file);
number = '2';
fputc(number, file);
fputc((int) ' ', file);
number = '3';
fputc(number, file);
fputc((int) ' ', file);
And the last number:
fputc(number, file);
fputc((int) '\n', file);
Or, if you got all numbers at the same time, you can do this:
fprintf(file, "%d %d %d %d\n", 1,2,3,4);
fprintf(file, "%d %d %d %d\n", 5,6,7,8);
This is very basic knowledge, I think you should read a good beginners book about C and then go on with a book about C++.
Good luck
Kakan
|
|
|
|
|
I have written an MFC application which uses CRecordset to communicate with MS Access database through ODBC. The problem is with moderate use, the program will appear to pause or hang.. then all database operations will become extremely slow. It is so slow that it is unusable! Is there any reason for this? all help will be appreciated. btw.. my program uses quite a number of recordsets.. e.g to fill comboboxes, update Clistctrls...
|
|
|
|
|
Have a look at its memory usage - Is it increasing and increasing to unreasonable levels? If not RAM is its CPU usage blowing up out of control? If you can give more details such as answers to the above questions you'll get a lot more suggestions.
Steve
|
|
|
|
|
the database operations in the program seem to be allocating awful amounts of memory, in the range of 500 kb for each operation. Is this a sign of a memory leak? also when the program comes to the stage where it is unuseable, the CPU usage doesn't read high. however, the memory usage seems to be quite high (in the range of 30,000 kb).. the program usually uses 14 to 20 mb of memory.
|
|
|
|
|
I don't think that's particularly excessive. If you leave it for an hour and come back how much memory is being used?
Steve
|
|
|
|
|