|
Did u try finding CHARFORMAT, its a structure that containg all the formating features... pretty useful with richedit ctrl.
|
|
|
|
|
yes it does, but nomatter what font I used (unicode fonts), still nothing but pure English.
|
|
|
|
|
HI all;
I am building an application which should have a tab control on a CDialogBar. Visual C++ gladly added the dockable dialog bar for me but i could not figure out where to put the code to create the tab control since the OnInitDialog() function is simply ineffective. Can anybody please help out. I need to know where i should place my code to create the TAb control on the dialogbar.
I badly need this guys;
THanks
Krugger
|
|
|
|
|
Hi, I can't find any way to resize class arrays
created using "new"
is it right to use C memory allocation functions for class arrays and then call constructors/destructors
|
|
|
|
|
You definitely wouldn't want to use realloc with an object created with new. You need to leave that old C stuff behind.
If you are using MFC CArray or better still STL vector then they will resize themselves as required.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
|
If you're using MFC, you can use SetSize() to preallocate a CArray 's storage. This is useful when optimizing deserialization of a collection. The size of the collection will grow as you add more elements.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Imagine the following scenario:
One of my applications communicates with another (3rd party, non open source) application via a simple TCP socket. The socket is only used to retrieve the status of the other app (or better, the other app sends its status over the socket). The packets are small, usually below 70 bytes, but they are sent pretty often (about 3-5 times per second). After my app receives a packet from the other app, it sends a small, 33 byte answer. After this answer, the other app sends a new status packet and so on. So much for the scenario...
Now there are two odd things going on.
The first oddity is a packet of 1024 bytes. This packet is mysteriously received by the other app, but I have no idea where this might come from (I'm using Port explorer, and it says that it should come from my app, but that's impossible). The packet arrives shortly after I've sent my "answer" to the other app. It contains my answer plus a lot of garbage. But that's not all...
After a while, the other app stops sending out its status to my app. But! It begins to receive even more of these 1024 byte packets - with the correct status at the beginning! Port explorer still says that all comes from my app, but that's totally impossible (I couldn't even guess the correct status).
So, where might these packets come from? What might make the other app stop sending out its status? Is there a way to get these 1024 byte packets?
|
|
|
|
|
Hi!
If you can post some of the code snippets, then there might a chance for a solution. At the moment it seems that you are allocating the buffer of size 1024, and fill in the first few bytes ans send it. Rest is garbage. And btw what kind of sockets you are using? Sync or Async etc.
Regards,
Bilal Anjum
|
|
|
|
|
No, your assumptions are wrong. My buffer is not 1024, and I am not sending it (as I stated, I CANNOT send it, I can't guess the contents of these packets). It is not that simple. The socket on my side is async, but that doesn't matter. I can't say what kind of socket the other program is using (I don't think that they use MFC at all).
And code snippets won't help - it's a simple derivated socket which receives stuff and sends a small reply (and this reply does not contain garbage, nor is it 1024 bytes long).
I can only say that these packages cannot come from my app. I neither can guess the contents of them (that would solve my problems, lol), nor do I send anything at that time (I only send sth. when I receive sth., and as I stated, I don't receive anything after a while... and even if I don't send anything at all these 1024 byte packages arrive at the other app).
|
|
|
|
|
Heres what I have...
<br />
{<br />
CMenu menu;<br />
<br />
menu.CreatePopupMenu();<br />
<br />
for (int x = 0; x < ndex; x++)<br />
{<br />
Swap = StrArr.GetAt(x);<br />
if (Swap != "Main")<br />
menu.AppendMenu(MF_STRING, x, Swap);<br />
}<br />
<br />
CPoint point;<br />
GetCursorPos(&point);<br />
SetForegroundWindow();<br />
int Sel = TrackPopupMenuEx(menu.GetSafeHmenu(), TPM_RETURNCMD, point.x, point.y, GetSafeHwnd(), NULL); <br />
PostMessage(WM_NULL, 0, 0);<br />
menu.DestroyMenu();<br />
}<br />
I've deleted variable declarations and some code to save space.
With the AppendMenu(), I'm of course adding menu items. What I want to do is add sub menus to each of these menu items.
Instead of clicking on an item and executing a function, I want a sub menu to pop up. Can't figure out how to do it.
Any help?
Thanks!
Daniel
|
|
|
|
|
The menu objects are always grouped as sub or pop-up menus. Now, considering your code post, there is one crucial difference in creating pop-up menus.
Firstly, you need to create a new CMenu object. Then initialize it with CreatePopupMenu like you have done. After that, you need to create a yet another CMenu item, and initialize it with CreatePopupMenu again.
The second menu object behaves like a pop-up menu on the first one. In order to link these two, first add items and their respective command IDs to the second menu by using AppendMenu or InsertMenu . Then use AppendMenu /InsertMenu on the first menu object, and specify MF_POPUP flag in the first parameter. Adding a MF_STRING flag allows you to have an item text as well, specified in the third parameter. Instead of a command ID in the second parameter, you now must supply a handle to the sub-menu object (HMENU ). You can get this from the second menu object by querying CMenu::operator HMENU or CMenu::m_hMenu .
After this, you can launch the first menu object as a pop-up menu with a sub pop-up by calling TrackPopupMenuEx . Here is a complete code fragment to give you a better clue:
CMenu* pMenu = new CMenu();
pMenu->CreatePopupMenu();<DIV>
CMenu* pSubMenu = new CMenu();
pSubMenu->CreatePopupMenu();<DIV>
pSubMenu->AppendMenu( MF_STRING, 1, "Option 1" );
pSubMenu->AppendMenu( MF_STRING, 2, "Option 2" );<DIV>
pMenu->AppendMenu( MF_STRING | MF_POPUP, (UINT_PTR) pSubMenu->m_hMenu, "Sub menu" );<DIV>
pMenu->TrackPopupMenuEx(...);<DIV>
pMenu->RemoveMenu( 0, MF_BYPOSITION );
pSubMenu->DestroyMenu(); delete pSubMenu; pSubMenu = NULL;
pMenu->DestroyMenu(); delete pMenu; pMenu = NULL; I am not certain if the RemoveMenu call is necessary, as the menu cleanup code might have a routine that destroys sub-menus as well. Also, the code has no error-checking routines for possible error states like memory reservation failures or checks whether the pointers are valid. You should include these, or your application might cause access violations.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hello @all,
I have a C-program with a telephone listing. Now I would like to examine with an entry into the telephone listing whether the entry is already present. How can I examine whether the name in other form (large and lower case) exists?
Thank you,
Lucky
|
|
|
|
|
|
I am trying to change the volume level using Windows API.
i just need to change it up and down.
How can i do that?
|
|
|
|
|
|
Hi....
i build an application to upload data retrived from database
via Http link but an error came as.......
===========================================================
="The Server returned an invalid or unrecognized response"=
===========================================================
this is the code for connect to the site....
CHttpConnection* pConnection;
CInternetSession session("Tear");
try
{
pConnection =session.GetHttpConnection(_T(m_EIP));
}
catch(CInternetException* pEx)
{
MessageBox("Error in Connection");
pEx->ReportError();
pEx->Delete();
}
pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,"/ddd.aspx");
pFile->AddRequestHeaders(strHeaders);
// code to retrive the data .........
strFormData = _T("tel="+mSMS_Mobile+"&Msg="+mSMS_Text+"&user="+m_EUN+"&pass="+m_EPW);
BOOL F2=pFile->SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData,strFormData.GetLength());
if (F2)
m_DATA.AddString(m_txt);
else
{
DWORD dwStatusCode;
CString error_no;
pFile->QueryInfoStatusCode(dwStatusCode);
error_no.Format("%s",dwStatusCode);
m_DATA.AddString(error_no);
}
|
|
|
|
|
Hi all,
I am writing a system where a client communicates with a server and amongst other things tells the server what the client's IP and subnet mask are. However, when there are more than 1 network cards on a PC, how can I programmaticaly know which interface a packet is going to be sent on (for a particular destination)? I know how to get a list of interfaces and relevant details but don't know which one to use.
Mark
|
|
|
|
|
mmica wrote:
I know how to get a list of interfaces and relevant details but don't know which one to use.
The routing service on the PC will determine from the destination address which interface to use. If, for some reason, you need to select an interface in your app, though, the information stored in the routing table for the PC should be sufficient.
Knowing the destination IP address and subnet mask, you should be able to compare it to the routing table in the machine to find which interface the address fits. If you AND the IP address of the host you want to reach with the subnet mask, the resulting network address should fit into one of the route specifications in the routing table.
The illustrations here - The IP Routing Table - MSDN[^] - provide examples and an excellent explanation of how they're used.
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
Hi,
How could I make folder as Public Share in windows98 system, so that i can be able to access those files from my service on other system with WindowsXP OS?
|
|
|
|
|
Hi, I'm trying to make a tool using MFC for a game I'm making. And I need a edit control to type in coordinates for objects, and in the end I have to get the coordinate value to be a float. I want the edit control to be fairly user friendly what should I do? Some tutorials seem to make their own classes derived from CEdit, or should I just make a member variable of CEdit type? I've tried making a member variable of type float but that doesn't really seem to let me format the string of the edit control to only accept numeric values etc. If I make a CEdit variable or make my own class derived from CEdit is there some way I can convert the string in the edit control to a float?? Any advice is apreciated
|
|
|
|
|
there are some masked edit controls here on cp that will do exactly what u are looking for
"there is no spoon" biz stuff about me
|
|
|
|
|
|
IN REPLY TO:
some way I can convert the string in the edit control to a float?? Any advice is apreciated
For argument sakes lets say you have an edit box IDC_EDITBOX
Lets say you go to class wizard and add a variable of type CString to that box lets call it m_editbox_string;
then you have a control of type CEdit for that box lets call it m_editbox_edit_control;
Lets say the user types in 2.0094 or whatever in the box
to convert the string do the following
float fHolder=0;
m_editbox_edit_control.GetWindowText(m_editbox_string);
fHolder = atof(m_editbox_string);//atof converts the string to a float
/***********************************************************************
abs
Find absolute value of integer
atof
Convert string to float
atoi, _atoi64
Convert string to int
atol
Convert string to long
_ecvt
Convert double to string of specified length
_fcvt
Convert double to string with specified number of digits following decimal point
_gcvt
Convert double number to string; store string in buffer
_itoa, _i64toa, _itow, _i64tow
Convert int to string
labs
Find absolute value of long integer
_ltoa, _ltow
Convert long to string
_mbbtombc
Convert 1-byte multibyte character to corresponding 2-byte multibyte character
_mbcjistojms
Convert Japan Industry Standard (JIS) character to Japan Microsoft (JMS) character
_mbcjmstojis
Convert JMS character to JIS character
_mbctohira
Convert multibyte character to 1-byte hiragana code
_mbctokata
Convert multibyte character to 1-byte katakana code
_mbctombb
Convert 2-byte multibyte character to corresponding 1-byte multibyte character
mbstowcs
Convert sequence of multibyte characters to corresponding sequence of wide characters
mbtowc
Convert multibyte character to corresponding wide character
strtod, wcstod
Convert string to double
strtol, wcstol
Convert string to long integer
strtoul, wcstoul
Convert string to unsigned long integer
strxfrm, wcsxfrm
Transform string into collated form based on locale-specific information
__toascii
Convert character to ASCII code
tolower, towlower, _mbctolower
Test character and convert to lowercase if currently uppercase
_tolower
Convert character to lowercase unconditionally
toupper, towupper, _mbctoupper
Test character and convert to uppercase if currently lowercase
_toupper
Convert character to uppercase unconditionally
_ultoa, _ultow
Convert unsigned long to string
wcstombs
Convert sequence of wide characters to corresponding sequence of multibyte characters
wctomb
Convert wide character to corresponding multibyte character
_wtoi
Convert wide-character string to int
_wtol
Convert wide-character string to long
************************************************************************/
Hope this helps,
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
Thanks alot guys that really helps, one more question though. I'm pretty new to MFC and I've noticed in some tutorials here about numeric edit boxes that they derive a class from CEdit and then in the Visual C++ editor they create a Edit box, and then they write somthing like DDX_Control(blah blah) into the DoDataExchange function...And then the program runs and the edit box only accepts numbers or whatever there derived CEdit class tells it to accept....but in the editor they create a normal edit control, how do they make it so that there edit control gets replaced with that one?
|
|
|
|
|