|
Hi Srikanth,
Also make sure you hit reply on my messages if you want me to see your replies.
It was just by chance I looked this far into old messages and saw that you had replied
Mark
|
|
|
|
|
Hi,
does anyone know a trick how to get the ideal size for the CDateTimeCtrl to display all of its content in all formats it supports?
It doesn't resize itself to a proper size for its content and it seems it has alot of internal logic for sizing the various internal edit fields.
A simple GetWindowText() and GetOutputTextExent() doesn't work in all cases (i.e. when there are date/time formats set without leading zeros).
I know there is a special window message available on vista to fetch the ideal size of the CDateTimeCtrl, but what to do in previous windows versions ?
Many thanks,
Watz
|
|
|
|
|
You see, I'm not sure I really need a fully featured tabular control. I'm doing a fairly simple dialog based application using the AppWizard in VC++, which will load some ascii text files and display them in a table format. At some point in the future RS232 will read in new values but for now, it will be a case of editing a few edit controls and clicking a button to "push" a line of data into the table, comparing and doing some calculations on the way. I don't see that there'll be much need for the users to interact with the table other than I'd like at some point to be able to push that out to a print option
Is there an easy way to do this? I probably only need pointing in the right direction to start with.
t.i.a
Lee
|
|
|
|
|
|
thanks. I've not done a lot with VC++ for a while, and didn't correlate "List control" with "tabular data" when I saw that in the controls palette
|
|
|
|
|
Hello All,
I added a Rich Edit Box to my dialog and executed the dialog now the problem is dialog is not getting displayed & no action is performed or any error is displaed.
Guys can u please tell me hw to add a Rich Edit Control to my Dialog using Win32 App. ???
Thanking you,
Suresh HC
|
|
|
|
|
You need to call AfxInitRichEdit to initialize rich edit control for app.
Call this function in your application.
|
|
|
|
|
Hi Prasad,
Thansk for the responce.
I called AfxInitRichEdit(); in my Dialog,
I am getting error C2065: 'AfxInitRichEdit' : undeclared identifier
Dialog which I have created is from win32 Application and not from MFC.
Can u please tell me hw use rich edit box in win 32 application.
|
|
|
|
|
Use LoadLibrary for initializing rich edit control.
You main window procedure would look like this,
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_CREATE:
hLib = LoadLibrary("RICHED32.DLL");
break;
case WM_CLOSE:
DestroyWindow(hwnd);
FreeLibrary(hLib);
break;
..
}
|
|
|
|
|
Hi Prasad,
what shd be the hlib variable type ??? and where we have to declare that variable??
error C2065: 'hLib' : undeclared identifier
|
|
|
|
|
Its HMODULE . You can declare it as
HMODULE hLib;
I've just given example.
Only thing important, you need to load dll before invoking dialog.
|
|
|
|
|
Hi Prasad,
I did changes as u have mentioned.
But still no changes , still the dialog is not getting displayed which contains rich edit box.If i remove the Rich edit control Dialog is getting displayed.
I have 3 dialogs one main another sub dialogs , in the sub dialog I have the rich edit control.
The main MainDlgProc
<br />
BOOL CALLBACK MainDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)<br />
{<br />
HMODULE hLib;<br />
switch(Message)<br />
{<br />
<br />
case WM_CREATE:<br />
hLib = LoadLibrary("RICHED32.DLL");<br />
break;
and the sub dialog DlgProc
<br />
BOOL CALLBACK SearchDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)<br />
{<br />
HMODULE hLib;<br />
switch(Message)<br />
{<br />
case WM_CREATE:<br />
hLib = LoadLibrary("RICHED32.DLL");<br />
break; <br />
I am using windows 2000 OS with VC6.
|
|
|
|
|
Dear ! dear !
I mentioned in earlier reply, you need to load library before invoking dilaog. I'd assumed , you main application window is not dialog window in question, and window procedure I mentioned is of main window. So use given procedure with main window.
You should get idea from this snippet,
hLib = LoadLibrary("RICHED32.DLL");
ret = DialogBox(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_MYDLG), hwnd, MyDlgProc);
if(ret == -1)
{
MessageBox(hwnd, "Dialog failed!", "Error",
MB_OK | MB_ICONINFORMATION);
}
FreeLibrary(hLib );
|
|
|
|
|
At last ………Its working ……
Thanks a lot Prasad …. I actually adding the dll file load in DlgProc after dialog load that my mistake which I did … now I have added in the WinMain ..now the dialog is getting displayed with the rich control.
Thanks a lot Prasad once again …
|
|
|
|
|
If you want to use of functions on a dll you need first to load it dll and then use of functions
|
|
|
|
|
How to get value in 16 bit interger from buffer..thanks in advance.
uint16_t value;
buffer->buf[buffer->buf_end++] = 0x03; //1 byte
buffer->buf[buffer->buf_end++] = 0xe8; //1 byte
Now I want to get like
value= 0x3e8
thanks.
|
|
|
|
|
Play it again, Sam?
value = (buffer->buf[buffer->buf_end-2]) << 8 | (buffer->buf[buffer->buf_end-1]);
Note that if yoou load the buffer in reverse order the you can do the quick and dirty:
value = *((unsigned short *)& buffer[buffer->buf_end-2] );
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
thanks ---i manage to do that by ur help
value=(buffer->buf[buffer->buf_ptr+1] << 8 | (buffer->buf[buffer->buf_ptr+2]));
|
|
|
|
|
uint16_t value;<br />
<br />
value = 0x03;
value * 256; <br />
value += 0xe8;
Multiplying by 256 shifts the bits to the left by 8 bits (thus 1 byte).
|
|
|
|
|
Cpallini already answered your question but I am curious to know why you are using ‘uint16_t’. The reason I ask is that other than making it clear that it is a 16-bit value, I can only guess why Microsoft has even defined it as a type. As you may know an ‘unsigned short’ is defined in C, and C++, as a 16-bit value and therefore redefining it makes little since to me.
Signed: Curious
|
|
|
|
|
When I click on minimize box, my CDialog derived window goes to taskbar but also ALL other thread-separated CDialog windows minimize?! How to fix it? Those thread-separated windows are modeless, created in InitInstance() of CWinThread derived class.
Thanks for help
|
|
|
|
|
By default, parent of dialog is set to NULL . Which makes application's main window as parent of dialog. Which is happening in your case.
To avoid it, you can set desktop window as parent window of dialog you dont want to minimize with main dialog. But, in this case, this dialog will appear in taskbar,too.
|
|
|
|
|
Thanks, that explains a lot. So, creating dialogs with desktop as a parent window will make those windows full separated from the application's main window? I ask because now when I create dialogs with NULL parent window, I cannot move main application's window on the top of their 'children' by activating it. It is getting the focus, titlebar is changing to active and all controls work but the window is not placed on the top of other windows. Is it also this case or something else is going on?
Thanks again
|
|
|
|
|
PatrykDabrowski wrote: Is it also this case
I dont think so.
|
|
|
|
|
I have created a class whos duty is to return a full path to the requested file. In the C'tor I allocate a string and store the exe's folder. Since strings are often returned there is a szReturnBuffer[MAX_PATH] buffer. In later calls to the methods I build a path from the earlier retrieved path and append the file/directory.
Here's the relevent code:
CGameSettings::CGameSettings( void )
{
m_szLocalDirectory = NULL;
DWORD dwLen = ::GetModuleFileName( NULL, m_szReturnBuffer, sizeof(m_szReturnBuffer) );
if ( dwLen )
{
::PathRemoveFileSpec( m_szReturnBuffer );
::PathAddBackslash( m_szReturnBuffer );
dwLen = (DWORD)_tcslen( m_szReturnBuffer ) + 1;
m_szLocalDirectory = new TCHAR [ dwLen ];
if ( m_szLocalDirectory )
_stprintf_s( m_szLocalDirectory, dwLen, _T("%s"), m_szReturnBuffer );
}
}
LPCTSTR CGameSettings::GetBkgndFolder( void )
{
if ( ! m_szLocalDirectory )
return NULL;
_stprintf_s(
m_szReturnBuffer,
sizeof(m_szReturnBuffer),
_T("%s%s"),
m_szLocalDirectory,
_T("Art\\Background\\") );
return m_szReturnBuffer;
}
m_szReturnBuffer contains the correct path, but the _stprintf_s somehow sets the m_szLocalDirectory to 0xfdfdfdfd . What could be causing this?
|
|
|
|