|
Hi All
I am facing very fracturing problem.My application some control move from original position and some control hide.i use Static,Edit Box,List Box,List Control,Picture control and Spin Control.
I use OnEraseBkgnd and OnCtlColor function for background color and control color.Code is here
HBRUSH CTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if((pWnd->GetDlgCtrlID() == IDC_CHECK_REAL) || (pWnd->GetDlgCtrlID() == IDC_STATIC_REAL))
{
hbr = CreateSolidBrush(RGB(250, 252 , 254));
pDC->SetBkColor(RGB(250,252,254));
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkMode(OPAQUE);
}
if((pWnd->GetDlgCtrlID() == IDC_EDIT_MAXPATH))
{
hbr = CreateSolidBrush(RGB(255, 255 ,255));
pDC->SetBkColor(RGB(255, 255 , 255));
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkMode(OPAQUE);
}
}
BOOL CtESTDlg::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect(&rect);
pDC->FillSolidRect(rect,RGB(250,252,254));
return TRUE;
}
|
|
|
|
|
Hi sir.
When i type any character in the CombBox.I am sorting and displaying the results in dropdown.
But the first string which comes in DropDown is being set in ComboBox.
For Ex: If i have some strings in CComboBox : 1)"Pas",2)"Pad"
When i type P in Combo the same "P" character must be set to the ComboBox not "Pas".
Any idea will be thankful
Thanks
Raj
|
|
|
|
|
you can not directly enter values in comboBox.
You can use like this
CComboBox* test;
for (int i=0;i< test->GetCount();i++)
{
test->SetItemData(i, i);
}
|
|
|
|
|
Hello All,
General Idea:- I am developing application win32 cleint server type (It is like desktop monitoring ).
On server side I am takeing screen shot. & sending it to client side.
On server side I have function code like
--------------------------------------------
|
|
|
<pre><pre>hdc1 = GetDC(NULL);
hdc2 = CreateCompatibleDC(hdc1);
GetWindowRect(GetDesktopWindow(), &rc);
w = rc.right-rc.left;
h = rc.bottom-rc.top;
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biWidth = w;
bmih.biHeight = h;
bmih.biPlanes = 1;
bmih.biBitCount = 24;
bmih.biCompression = BI_RGB;
bmih.biSizeImage = ((((bmih.biWidth * bmih.biBitCount) + 31) & ~31) >> 3) * bmih.biHeight;
bi.bmiHeader = bmih;
aBmp = CreateDIBSection(hdc1, &bi ,DIB_RGB_COLORS, (void**)&dibvalues, NULL, NULL);
OldObj = SelectObject(hdc2, aBmp);
BitBlt(hdc2, 0, 0, w, h, hdc1, 0, 0, SRCCOPY);</pre>
//////////////////////////////////////////////////////////////</pre>
I have class like
<pre>class DesktopScreen{
public:
BITMAPINFOHEADER bmih ;
BITMAPINFO bi; unsigned char dibvalues[lenght]; };</pre>------------------------------------------------------------------
using above code I am filling Object of this class & sending it to other side
in binary formate (byte).
On Client side deserializing is also OK (I check all value at time of debuging )
<pre>Now at time WM_Paint:
hDC = BeginPaint(hWnd, &Ps);
i= StretchDIBits(hDC, // destination rectangle 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), // source rectangle 0, 0,desktopObj.bmih.biWidth , desktopObj.bmih.biHeight, desktopObj.dibvalues, &desktopObj.bi, DIB_RGB_COLORS, SRCCOPY);
//////////////////////////////////////////////////////////////////////////</pre>
StretchDIBits is returning 0 .
Application run properlly but image is not displying.
also if i call StretchDIBits on server side passing same info to that function.I mages is displaying.
Can you please tell me what should be the problem.
( sorry for posting code ,but I think it is necessary to get my Question to you )
Thanks ,
Ashish.
|
|
|
|
|
Hi I want to create ownerdraw combobox. But whenever I m calling the create function its giving assertion error. Can anybody tell me why its happeing.
here is code :
void CTxComboBoxCtrl::CreateCustomComboBox(CRect rect, CWnd* pWnd, UINT nID)
{
this->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL|CBS_HASSTRINGS |CBS_DROPDOWNLIST |CBS_OWNERDRAWVARIABLE ,rect,pWnd,nID);
}
CTxComboBoxCtrl id derived from CComboBox class
Thanks..
|
|
|
|
|
|
ys I m overriding the ownerdraw function. but its giving arrestion error on the beginging its self when I m calling create function from oninitdialog funuction of the dailog.
|
|
|
|
|
Please show us the ASSERT code.
|
|
|
|
|
In this line its giving assertion :
void CComboBox::MeasureItem(LPMEASUREITEMSTRUCT)
{ ASSERT(FALSE); }
|
|
|
|
|
This tells you exactly what's wrong - you haven't overidden MeasureItem in your derived class so MFC's telling you to go and do it rather than letting your code crash in a novel and interesting way later.
Cheers,
Ash
|
|
|
|
|
Since you've given CBS_OWNERDRAWVARIABLE as combo style, you need override MeasureItem.
|
|
|
|
|
Quick hint: When the assertion fires you usually get the option to go to the line that triggered the assertion. Use a debugger when the assertion fires, have a dig around and try and relate the state of the code where you are to the parameters you passed into the Create function.
It could be that you're trying to create a window with the same ID to one already in existence in a dialogue box (in which case you might need to subclass an existing control instead) or the style parameters don't work for this class. The trouble is we have no idea why/where this is happening as you can go straight to the code causing the problem and get an idea without much effort.
Cheers,
Ash
|
|
|
|
|
how can I write a function to swap to different sized string?
|
|
|
|
|
What do you mean exactly ? Could you provide an example describing what you are looking for ?
|
|
|
|
|
Like in main function I will read two string from user. I will store the string either in array of fixed size or in a pointer or simply say in the main() there are two strings:
char *c = "MSN"
char *d = "YAHOO"
I have to pass these two string in a function say swapstrings() and swap these two variables
|
|
|
|
|
You might feel this is being overly pedantic... trust me it's not. You don't store strings in pointers - all you store in pointers are addresses. It just so happens that the character pointers you're talking about point to the first character of the block of memory you've got the characters representing the string in.
If you understand that then it should be fairly easy to work out how to switch the pointers around and get the result you're after.
Cheers,
Ash
|
|
|
|
|
I cannot understand what is the difficulty in writing that?
can you clarify your question.
Величие не Бога может быть недооценена.
|
|
|
|
|
the issue occurs with the different sized strings
|
|
|
|
|
inline void inventTheWheel(std::string &s1, std::string &s2)
{
std::swap(s1, s2);
}
Another way is to just use the std::swap function directly.
|
|
|
|
|
|
Just swap their pointers :
{
LPSTR lpStrA("12345");
LPSTR lpStrB("0987654321");
LPSTR lpTemp(lpStrA);
lpStrA = lpStrB;
lpStrB = lpTemp;
}
virtual void BeHappy() = 0;
|
|
|
|
|
If you're using C++ you don't need to write a function to do it, you just use std::swap.
If you're using C then you've got two choices:
- Swap the pointers to the arrays of characters you're interested in. IF you can get away with this it's pretty quick.
- If you've really got to move characters between arrays then they'd better both be large enough to accomodate the text in either string. You can either exchange each character over the first N characters where the number of characters is equal to the length of the longest string OR do a circular copy through a third buffer the length of the longest string. The circular copy method means you can use strcpy though.
Cheers,
Ash
|
|
|
|
|
thanks ash for the clarification
|
|
|
|
|
Hi!
I've to create an Array of Buttons. I've created using the following code.
s32 uright_x = 10;
s32 uright_y = 180;
s32 lleft_x = 20;
s32 lleft_y = 200;
s32 id = 0;
for(u32 i = 0; i<=14;i++)
{
irr::core::array<irr::gui::IGUIButton*> m_pPlayerBtn[i].push_back(pManager->getGUIEnvironment()->addButton(rect<s32>(uright_x, uright_y, lleft_x+50, lleft_y+50), 0, id++, 0, 0));
u32 size = m_pPlayerBtn->size();
printf("id %u", id);
}
When I run this code, only one button is displayed. But the printf("id %u", id); prints id of all the
15 buttons(from 1 to 15). Why only one but is displayed though all the buttons are created(since id is getting updated)? How to make all the button displayed? I've incremented the positions also.
|
|
|
|
|
You don't increment the position of your buttons in the loop, which means they are correctly created but stacked on top of each other. Which means that only the last created one is visible.
|
|
|
|