|
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.
|
|
|
|
|
Thanks a lot. It's working.
|
|
|
|
|
My code is not running in BHO. It's an exe.
Actually i want to save WebPage's filled values with 'id'of the field. So that in future i can refer a (saved) perticular field value with respect to it's Input-element 'id' value .
I able to do both save & refer the value of a field with respect to the value of Input-element 'type'. But problem is there, if suppose a web page having 2 TEXT-type fields --Text1 & Text2,then when i'm after saving those values, referring the values ,my code pointing those Text1 & Text2 fields's values as if the values of Text1 field. Because both field's Input 'type' element's value is same "text".
Actually i'hv to save the LoginPage field value of 'www.redbox.com'.But it's most fields don't have common Inpute element 'name'.Other wise we could have a abstract by IHTMLInputElement->get_name()
Only way, we can point both values of 2 different TEXT-type fields separately by saving their values along with Input 'id' element's value respectfully.Because we can notice id's of 2 different TEXT-type field's are different even though their Input 'type' value[text] are same .
So can you please have a look on my attempt & please if possible rectify,why its getting crashed as soon as a web page opened in Internet Explorer 8
IHTMLElement *pElement;
IDispatch *pDispInput = NULL;
HRESULT hr;
TCHAR tChrID[500];
BSTR bStrID;
if ( pDispInput->QueryInterface(IID_IHTMLElement, (void **)&pElement)== S_OK)
{
hr = pElement->get_id(&bStrID);
if (SUCCEEDED(hr))
{
CString StrS;
if (bStrID)
{
WideCharToMultiByte(CP_ACP, 0, bStrID, -1, tChrID, 500, NULL, NULL);
SysFreeString (bStrID);
}
StrS = tChrID;
WriteToLog(StrS);
}
pElement ->Release();
}
pDispInput->Release();
Please guide soon
Thankx
|
|
|
|
|
Pk.j wrote: if ( pDispInput->QueryInterface(IID_IHTMLElement, (void **)&pElement)== S_OK)
You are calling QueryInterface on a NULL pointer.
Regards,
Sandip.
|
|
|
|
|
|
Have you any idea which can help me further
|
|
|
|
|
IDispatch *pDispInput = NULL;
pDispInput->QueryInterface(IID_IHTMLElement, (void **)&pElement);
...or do you get the IDispatch pointer from somewhere else?
|
|
|
|
|
No i have declared IDispatch as in my sent code stuff. Or any thing you are pointing towards.
Please give me a clear Idea. If you have any samples on this IHTMLElement to retieve 'id' Input element's value, then please let me know soon.
Thankx
|
|
|
|
|
I know of no other way than to recursively traverse all html nodes and look for the text input type.
1. First you need the document. If you have a CHTMLView derived class you get this by calling GetHtmlDocument(): If you have a WebBrowser control you use get_Document().
2. Query the dispatch interface for the IID_IHTMLDocument2 interface.
3. Use get_All (get_Forms is not enough since you might have input fields outside of a form tag.)
4. Traverse all elements in the returned elements collection. And recursively for their children.
5. Check if a specific element is an input with type text. Use tagName and getAttribute from IHTMLElement.
6. Use get_id.
|
|
|
|
|
Hi,
This CDialogBar is very confusing
The Doc says create/instatiate in MainFrame OnCreate
but.....
I want to use it later on in my modeless Dialog Box
do I create it on the heap.... via new and save the pointer
then do a ShowWindow in my Oninitdialog handler
can anyone give me guidence
|
|
|
|
|
I assume you are building CFrameWnd based application which is needed to use the CDialogBar. Here I also assume you will be using the CDialogBar in a CMainFrame class (and not a CChildFrame which is also possible)
You can create the CDialogBar whenever you'd like after the main window has been created (you normally set the frame window as the parent of the CDialogBar). So you can create it when you need it i.e. when your modless dialog is opened.
It might however be more practical to create it in CMainFrame::OnCreate initially hidden and then just show/hide the CDialogBar when needed. The reason for this is the LoadBarState/SaveBarState API used to store the docking state of docking windows. It is much easier to handle LoadBarState on application start-up and SaveBarState on exit for all dockable windows at once and not make any special arrangements for a specific CDialogBar. If this is not important, you can create the CDialogBar whenever you want.
|
|
|
|
|
A more specfic question can CdialogBar be used in a modless CDialog or was it meant for the CMainFrame
class
|
|
|
|