|
Flace wrote:
All projects in VC6 seem to have MBCS defined by default.
Always the first thing i change.
I always set to either UNICODE or nothing.
I always explicitly use unicode or ansii string class'/functions.
Not a big fan of this whole 'it may be ansii, it may be unicode, it may be mb'.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
class CEncoderView is a MDI's view class. class CBMWin which derived from class CWnd is the subwindow of class CEncoderView.
I want to save the view as a DIB, so that I firstly DoModal a dialog for getting the DIB file's path. then I send a message MY_SAVEWHOLE which is handled in DefWindowProc to save the view as a DIB file.But I find the dialog is also appeared in the DIB file.
In order to clear the dialog, I invalidate the whole desktop befor saving the view shown as step 1 in the source code below. At this time, there are only the subwindow frames be showed in the DIB. they client rect is empty,because they did't redraw themselves.
In step 2 shown in the source code below, I get messages from the message queue. I want to save the view after all of its subwindows have send a message MY_REDRAW to it. But I find that the function GetMessage can't retrieve message MY_REDRAW at label A in the source code below. Meanwhile, I can retrieve the message MY_REDRAW in the function DefWindowProc at label B which shown in the source code below.
How the message be dispatch in the window?
#define MY_SAVEWHOLE WM_APP + 2 //save a view window as a file
#define MY_REDRAW WM_APP + 3 //have redrawed a subwindow
void CEncoderView::OnExportimage()
{
CExportImageDlg exportidlg( this );
int nRet = -1;
nRet = exportidlg.DoModal();
if (( nRet == -1 ) || ( nRet == IDABORT ))
{
AfxMessageBox( "Dialog box could not be created!");
return;
}
if ( nRet != IDOK )
{
return;
}
//added in step 1
//redraw all windows
::InvalidateRect( NULL, NULL, FALSE );
//end of added in step 1
//added in step 2
//the number of subwindows whose type isCBMWin
int iRedrawedSubWin = 0;
MSG msg;
int bRet;
//if all of the subwindows had redrawed themselves
//then save the view as a DIB
while(( iRedrawedSubWin < iSubWinNum ) &&
((bRet = ::GetMessage( &msg, NULL, 0, 0 )) != 0))
{
//can't retrieve message MY_REDRAW at this point
if ( msg.message == MY_REDRAW )
{
//never execute,can't retrieved message MY_REDRAW
label A: iRedrawedSubWin++;
}
if (bRet == -1)
{
break;// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
//end of added in step 2
::SendMessage( m_hWnd, MY_SAVEWHOLE, ( WPARAM )( &exportidlg.m_CSFileRoute ), NULL );
}
LRESULT CEncoderView::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
CBMWin* pChildWnd = NULL;
int iRetValue;
PBITMAPINFO pBitmapInfo = NULL;
switch( message )
{
case MY_SAVEWHOLE:
iRetValue = Win2DIB( this, &pBitmapInfo);
if ( iRetValue != ERR_OK )
{
return 0;
}
SaveDIBFile( pBitmapInfo, ( CString* )wParam );
free( pBitmapInfo );
return 0;
case MY_REDRAW:
//when subwindow redraw,this message can be retrieved
label B: iRetValue = 0; //no mean.
}
return CView::DefWindowProc(message, wParam, lParam);
}
void CBMWin::OnPaint()
{
CPaintDC dc(this); // device context for painting
RECT rect;
GetClientRect( &rect );
//draw a DIB on the client rect
StretchDIBits( dc,
0, 0, rect.right, rect.bottom,
0, 0, ...);
//tell the prarent window CEncoderView it has redrawed itself
::SendMessage( GetParent()->m_hWnd, MY_REDRAW, NULL, NULL );
}
andy
|
|
|
|
|
How to fix (custom ActiveX)control size in design time.
I am using MFC ActiveX ControlWizard.
Please help me.
Thanks
David Park
|
|
|
|
|
Hello,
I am currently trying to change from VB .Net to VC++ .Net.
I am trying to take information from a KeyUp event in the main form (form1), and put the KeyData into label1->Text .
Here is my code:
private: System::Void Form1_KeyUp(System::Object * sender, System::Windows::Forms::KeyEventArgs * e)
{
label1->Text = e->KeyData;
}
However, it returns me the error saying that "c:\...\TestingC++\Form1.h(96): error C2664: 'System::Windows::Forms::Control::set_Text' : cannot convert parameter 1 from 'System::Windows::Forms::Keys' to 'System::String __gc *'"
What should I do to correct this error?
Any help will be greatly appreciated,
Programmer2k4
My sig:
"And it is a professional faux pas to pay someone else to destroy your computer when you are perfectly capable of destroying it yourself." - Roger Wright
I now use my CodeProject Blog!
Most recent blog post: March 24
|
|
|
|
|
That is because the KeyValue return int.
[C++]
public: __property int get_KeyValue();
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Is there any way, given a certain font, to know if a specific character will be able to be rendered properly or will be displayed as a "I-don't-know-how-to-draw-this" box.
I want to display some Japanese text, but only if the font is going to be able to render it properly.
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin
Awasu 2.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Hi,
I want to change the size of array in run-time without loosing the elemnts of array.
Best wishes,
Thanks.
|
|
|
|
|
hum, I really wonder that you don't know C++ quite well.
i already post for you something about operator new .
if you want to change the size of an array (of course, without loosing its content), you allocate a new array (with the new size), you copy the existing datas from the previous array, you delete the old array...
that's quite simple, but if you have to perform lots of operation of this type on an array, you'd better have a look at the STL containers, especially list<> and vector<>
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Look at realloc, it does just this. If you want to change the array size very offen, you better use stl vector. But unfortunately, stl with vc++ requires a dll(I forgot the name) to be present on the system, so you have to distribute it.
|
|
|
|
|
realloc() is not "re-entrant" (i'm not sure about how to say this in english. this C function is to avoid. Moreover, we have powerful tools in the Standard C++ Library that are optimized to do plenty of arrays' size modifications...
Another thing : vector<> do only need <VECTOR> header to be included in the source, but no DLL at all...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
STL requires msvcp60.dll which, ironically, is not present on a freshly installed Win2k or WinXP.
|
|
|
|
|
strangely, i never encountered the problem...
so, you'll answer, oh, that's because i've just said "on a freshly installed Win2k or WinXP". yep, BUT, i already programmed on "freshly installed WinXP" (on VMWare if you know) cause my own PC was running under Win2K... the only problem i had is that the Bluetooth functions I needed were not present on the pack I had of MS Visual Studio .NET, but no problem with vectors...
i can't explain more, i don't think i have a ghost that installed "msvcp60.dll" on my system when i was watching at it... :->
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
MS Visual Studio .NET is the ghost in your case.
Its just my experience, believe it or experience it yourselves
|
|
|
|
|
it is a program of MSDN , which i have written in console win32 application because in win32 applicaiton it was also giving problems.It gives an error that SetDICreateDeviceInfoList() does not take 7 parameters....Plz help me out i also used debug mode still i was unable to derive the hardware list
#include <windows.h>
#include <setupapi.h>
#include <stdio.h>
DWORD Err;
HDEVINFO DoDeviceEnum( GUID InterfaceClassGuid)
/*
Routine Description:
Retrieves the device information set that contains that contains
the devices of the specified class.
Parameters:
InterfaceClassGuid - The interface class GUID.
Return Value:
If the function succeeds, the return value is a handle to the
device information set.
If the function fails, the return value is zero.
*/
{
HDEVINFO DeviceInfoSet;
HDEVINFO NewDeviceInfoSet;
// Create a device information set that will be the container for
// the device interfaces.
DeviceInfoSet = SetupDiCreateDeviceInfoList(NULL, NULL);
if(DeviceInfoSet == INVALID_HANDLE_VALUE) {
Err = GetLastError();
printf( "SetupDiCreateDeviceInfoList failed: %lx.\n", Err );
return 0;
}
// Retrieve the device information set for the interface class.
NewDeviceInfoSet=SetupDiGetClassDevsEx( InterfaceClassGuid,NULL,NULL,DIGCF_PRESENT | DIGCF_DEVICEINTERFACE,DeviceInfoSet,NULL,NULL);
if(NewDeviceInfoSet == INVALID_HANDLE_VALUE)
{
Err = GetLastError();
printf( "SetupDiGetClassDevsEx failed: %lx.\n", Err );
return 0;
}
return NewDeviceInfoSet;
}
int main(int argc, TCHAR* argv[])
{
DoDeviceEnum(NULL);
return 0;
}
|
|
|
|
|
i included the windows.h,setupapi.h,stdio.h
i want the computer to enumerate the hardware devices like
mouse,key board, NIC etc....
thanks
|
|
|
|
|
search in the forum, this question has been asked few days ago...
(maybe it was you )
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
this question has been asked few days ago...
(maybe it was you)
Indeed, at least three separate times.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
i need the similar which can read quickly and show quikly within 'CWnd',
compability diff format graph such as 'gif', 'bmp', 'png' etc.
specialy, biggest graph!!!
I know CxImage is a very strong libaray for dealing diff format graph, but it don't support biggest graph that can read and show image, thus, i will search other...
who can help me? thanks!!!
|
|
|
|
|
i am kinda new to C++. So, here is a question: what does enum type make the program different? personally, i see it as an array. am i wrong?
|
|
|
|
|
Check this article out.[^]
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
- -Uknown.
|
|
|
|
|
I'm not much of a C++ programmer myself, but I see enum variables as integers with a restricted set of values, like the old set type in Pascal. The list of possible values for an enum are mapped to integers which can be assigned explicitly or automatically. The declaration
enum Colors (Red, Blue, Yellow);
assigns integer tokens to represent the words "Red," "Blue," and "Yellow" but in the program you don't have to worry about what value was assigned; you only have to worry about trying to assign a variable of the type Colors a value other than one of those in the list.
If you're worried about it you can also assign the integer values -
enum DaysOfTheWeek (Mon=1, Tue=2, Wed=3, Thu=4, Fri=5, Sat=6, Sun=7);
If you later declare a variable
DaysOfTheWeek Today;
You can assign it the value of 3 or Wed and still get the same result:
Today=3;
if (Today == Wed) doSomething();
will execute doSomething().
Enums greatly improve program readability, and help to reduce maintenance costs. In a way they are like arrays, or more accurately vectors as they have only one dimension. But arrays and vectors are not limited in the values they contain (other than the limitations of their types). Enums are, by definition, restricted to certain values that you define.
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|
|
if i m using C in MFC right, in ListBox_GetSelItems(hCtrl, count, intArray) will it stores all the selected no in the intArray??
i m using the method below, but its stil not working!!can i know why???
total = ListBox_GetCount(hCtrl);
ListBox_GetSelItems(hCtrl, count, &lstItems);
// ListBox_GetSelItems(hCtrl, count, ArrayInt.GetData(hCtrl));
_stprintf(TextDisp, "Count = %d", count);
DispMsg(TextDisp);
for(i = 0 ; i < total ; i++)
{
if(iCount <= count && lstItems[iCount] == i)
{
DispMsg("True");
ListBox_GetText(hCtrl, lstItems[i], tmp );
hCtrl = GetDlgItem(hDlg, IDC_LVLSQ_SESSADJ );
ListBox_AddString(hCtrl, tmp) ;
DispMsg(tmp);
iCount = iCount + 1;
}else
{
DispMsg("False");
}
}
please Help me anyone...i hav try this for too long!!
|
|
|
|
|
Is this any better?
int nCount = ListBox_GetSelCount(hCtrl);
int *pArray = new int[nCount];
ListBox_GetSelItems(hCtrl, nCount, pArray);
for (int x = 0; x < nCount; x++)
{
ListBox_GetText(hCtrl, *(pArray + x), tmp);
DispMsg(tmp);
}
delete [] pArray;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Dumb question.. I'm sure it's super easy but I can't figure it out for what ever reason...
How can I replace all the 0x0a char's in a string with " \\line " ?
Right now I am taking a char converting it into a CString and converting the string into RTF.. I'm having problems getting the 'new line' or 'line returns' put into the string.
Thanks,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|