|
I know,, i was referring to the other method, some special chars in the varsion string or something alike. Did you try that too?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
Anyways, you could try hooking CreateWindow for your application OR register a windows hook for your process and catch the WM_CREATE message and try to add the WS_EX_LAYOUTRTL flag to created windows using ModifyStyleEx (don't know if it can be modified at runtime).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
Hello everyone,
I've been experimenting with C++ and how to build a form with it (without MFC).
I've created two buttons at runtime with the following code:
(I used a bit of copying and pasting)
if (button1 == NULL)
{
button1 = ::CreateWindowEx(WS_EX_LEFT,L"button",L"Button1", WS_CHILD ,50,50,50,50,parent,NULL,::GetModuleHandle(NULL),NULL);
SendMessage(button1, WM_SETFONT, (WPARAM)defFont, MAKELPARAM(TRUE, 0));
::ShowWindow(button1,SW_SHOW);
}
if (button2 == NULL)
{
button2 = ::CreateWindowEx(WS_EX_LEFT,L"button",L"Button2", WS_CHILD ,125,50,50,50,parent,NULL,::GetModuleHandle(NULL),NULL);
SendMessage(button2, WM_SETFONT, (WPARAM)defFont, MAKELPARAM(TRUE, 0));
::ShowWindow(button2,SW_SHOW);
}
There's no problem with building the buttons, this is my WndProc:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case SW_SHOW:
break;
case WM_COMMAND:
if (wParam == BN_CLICKED)
{
Triggered(L"1"); }
break;
case WM_SHOWWINDOW:
Init(hwnd); break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
How can I tell which one sent the message?
--
Nevermind, got it.
lParam equals with the (LPARAM)handle of the button that sent it.
modified on Tuesday, June 7, 2011 3:05 PM
|
|
|
|
|
When you call CreateWindowEx, the return is a handle to the button, that same handle can be used within the WPARAM or LPARAM to distinguish, or alternatively, if you have two button and you must distinguish, then they should probably be sending different messages.
|
|
|
|
|
Another way is to create button window with id.
button1 = ::CreateWindowEx(WS_EX_LEFT,L"button",L"Button1", WS_CHILD ,50,50,50,50,parent,(HMENU)100,::GetModuleHandle(NULL),NULL);
button2 = ::CreateWindowEx(WS_EX_LEFT,L"button",L"Button2", WS_CHILD ,125,50,50,50,parent,(HMENU)200,::GetModuleHandle(NULL),NULL);
Now you can distinguish which is which.
case WM_COMMAND:
if ((UINT)HIWORD(wParam) == BN_CLICKED)
{
switch (int)LOWORD(wParam):
{
case 100:
Triggered(L"1"); //Shows a messagebox.
break;
case 200:
Triggered(L"2"); //Shows a messagebox.
break;
}
}
break;
|
|
|
|
|
How can I get the title of this window and ensure it has certain specific text in it, to separate it from other notepad windows like it in C sharp? I have a program I'm trying to send controls to and the controls differ depending on the title and text of the window. I was using a DLL add on that will not function correctly in win7 because of the different way some GUI windows are drawn, so I wanted to make the entire app .net native.
Thanks for reading.
http://img683.imageshack.us/img683/3281/testgui1.jpg[^]
|
|
|
|
|
Post in C# forum... this is C/C++/MFC
|
|
|
|
|
My apologies, I clicked on the wrong link
|
|
|
|
|
I've done that in the past too, no worries... but you'll probably get better help over there...
|
|
|
|
|
Hi All,
The Api LoadInstanceString(..) is Failed it is giving an Empty String in Windows7 Operating system.
code.
-----
CString strTemp;
::LoadInstanceString(IDS_MSG_NODBQLPLANS, strTemp);
AfxMessageBox(strTemp);
Help me out.
Thanks & Regards,
uday
|
|
|
|
|
I cannot find any reference to LoadInstanceString() in MSDN, is this a standard part of the Windows API?
The best things in life are not things.
|
|
|
|
|
Hi,
I am Sorry
::LoadString(HINSTANCE hInst,UINT uid,LPWSTR,int len) Api is been Failed.
Code
----
_TCHAR buffer[2048];
LoadString(h, nResId, buffer, 2048); ---> Here the Code is been Failed for Windows7 O.S.
strMsg.Format(_T("%s"),buffer);
help me out.
Thanks & Regards,
uday.
modified on Tuesday, June 7, 2011 6:48 AM
|
|
|
|
|
Hi,
try to call GetLastError() and take a look to the error, can be usefull.
|
|
|
|
|
_TCHAR buffer[2048];
LoadString(h, nResId, buffer, 2048);
strMsg.Format(_T("%s"),buffer);
While i was running the application in WindowXP the Api is Working.
But when it is Window7 O.S the buffer is Empty.
There is no error.
Thanks
uday
|
|
|
|
|
janaswamy uday wrote: There is no error.
So LoadString() is returning a non-zero value?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I have just tried that and it works fine. Use the debugger to step through your code and check the values of all your parameters to see why it is failing.
The best things in life are not things.
|
|
|
|
|
janaswamy uday wrote: I am Sorry
::LoadString
A suggestion: when adding code to your question use copy and paste so the exact code from your program shows in the question.
The best things in life are not things.
|
|
|
|
|
I saw the following question as an interview question on one of the sites, Can anyone see if I answered correctly? Thanks
bool Item::SetInt( INT_STAT key, int val, UpdateType update )
{
m_Something->SetInt( key, val );
int i;
bool retval;
byte* buffer = new byte[ 256 ];
if ( update & No_UpdateType == No_UpdateType )
{
return false;
}
if ( update & Private_UpdateType == Private_UpdateType )
{
for ( i = 0; i < m_numEvents; ++i )
{
if ( m_eventFilter[i] == key )
{
retval = true;
}
else
{
retval = false;
}
}
if ( retval ) {
SendPrivateEvent( buffer, key, val );
}
}
if ( update & Public_UpdateType == Public_UpdateType )
{
for ( i = 0; i < m_numEvents; ++i )
{
if ( m_eventFilter[i] == key )
{
retval = true;
}
else
{
retval = false;
}
}
if ( retval )
{
SendPublicEvent( buffer, key, val );
}
}
delete buffer;
return retval;
}
My Answers:
|
|
|
|
|
With that indentation, it's a bit hard to read, but here are a few:
buffer will not be deallocated it the if statement after its assignment fires.
update & Private_UpdateType == Private_UpdateType is equivalent to
update & (Private_UpdateType == Private_UpdateType) which is probably not intended.
The for-loops does not add any value. There should probably be a break statement after retval = true; and retval = false; could be moved to before the loop.
...and to name relevant software principles: Code with bugs don't work as expected.
|
|
|
|
|
Heh, I wish I could keep my answers as concise as yours. You've beat me to it.
|
|
|
|
|
That's quite a novel Good effort!
|
|
|
|
|
Go, figure:
Apparently the intent of the function is to set a value which is bound to some key, but this functionality may have side-effects or may be varied depending on some flags which are passed with the last parameter.
The flags being handled are No_UpdateType, Private_UpdateType, and Public_UpdateType.
The function returns true or false, depending on whether or not certain tests, depending on these flags, are successful. Apparently the result should be true only if the key exists and the value could be successfully updated, but the implementation does not fully back up this assumption.
Problems and shortcomings:
The (member?) variable m_Something is being dereferenced without testing for 0. (Might be ascertained elsewhere, but the code doesn't indicate any of that) (style, possible error)
There is no (visible) test whether an element exist for the given key value before calling SetInt(). Although that code might be hidden in SetInt(), there should be an indication in case of failure, but apparently there is none. (style, possible error)
retval is not initialized, and not all execution paths assign a value to it. It may be undefined on return. (error)
The first if statement can lead to a premature return. Apart from the fact this is bad style, it will cause a memory leak, due to the fact that buffer will not be released. (style, memory leak)
Also, the flag No_UpdateType which this if statement tests for seems to hint at the possible meaning that no update should actually be performed, so the call to SetInt() right at the start of the function may have been premature. (possible error)
Moreover, the test is wrong: '==' has a higher precedence than '&', so the line
if ( update & No_UpdateType == No_UpdateType ) will be interpreted as
if ( update & (No_UpdateType == No_UpdateType) ) which in turn is equivalent to
if ( update ) . The test requires additional brackets like this:
if ( (update & No_UpdateType) == No_UpdateType ) (error)
The same error is repeated twice below. (error * 2)
The following two if blocks contain code that is partially identical. It would be a good idea to extract this code into a separate function, or at least to pull it out of the individual if blocks to prevent redundancy. (style)
The for loop in these blocks suffer from the following three problems:
1. retval is needlessly assigned once for every iteration (performance)
2. once an element equal to key is found, the loop could be abandoned (performance)
3. After this element has been found, retval is being overwritten with false again (error)
There is one more curiosity revealed in these loops: apparently there is some structure which is supposed to hold all key values, but at the same time, this key is being used to set a particular value within the object m_something. This hints at possibly redundant storage, or at least an inefficient way to store a mapping between some key and value. It would probably be a good idea to use a map or hash_map - this would also eliminate the need to implement your own key-searching and value-setting functions. (stlye, possible waste of resources)
The SendXY() functions use buffer before it is being initialized. (likely error * 2)
The two if blocks may both be executed, in which case the return value might be overwritten yet again. Not to mention that the same for loop would be executed twice. (likely error)
Wrong call to delete (error: should be delete []).
On a sidenote, if the size of the buffer should always be the same, it would be better to define it on the stack in stead of the heap! (style, performance)
Conclusion:
As indicated above, the implementation probably does not set the return value according to its intended meaning. I assume the functionality should be something like this:
bool Item::key_exists(int key) {
}
bool is_set(UpdateType update, UpdateType flag) {
return ( update & flag );
}
bool Item::SetInt() {
bool retval = key_exists(key);
if (!is_set(update, No_UpdateType)) {
retval = false;
}
if (retval) {
byte buffer[256];
m_something->SetInt(key, val);
if (is_set(update, Public_UpdateType)) {
SendPublic();
}
if (is_set(update, Private_UpdateType)) {
SendPrivate();
}
}
return retval;
}
|
|
|
|
|
|
Consider the very simple IDL code that specifies a base and derived interface in CORBA:
module test{
interface Quote{
attribute string symbol;
};
interface SpecialQuote:Quote{
attribute string specialSymbol;
};
interface QuoteSender{
void sendQuote(in Quote stock_quote);
}
};
(This assumes CORBA but should be similar for other middleware). I am interested in being able to:
1. create a derived class "SpecialQuote", fill in specialSymbol
2. upcast to the base class "Quote", fill in symbol
3. send over CORBA interface using "sendQuote"
4. on the receiving end, downcast to SpecialQuote to retrieve specialSymbol
I'm having a hard time performing this because the attributes essentially just translate to empty setters/getters in Java rather than their Primitive Data Types. Thus it requires both the client and server ends to re-implement the setters/getters.
So in short, is inheritance of interface **fields** possible across middleware without requiring a re-implementation in every language? If so in CORBA, any recommendations? If in another middleware, which one?
|
|
|
|
|
Hi!
I've developed a MFC application. It was running fine. Suddenl it stopped running. I didn't change any code. I could not run setup file and from IDE as
well. If I try to run in release mode:
'flash_mfc.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFCLOC_1fc8b3b9a1e18e3b_9.0.30729.4148_x-ww_15fc9313\mfc90enu.dll',
Binary was not built with debug information.
is displayed in the output window.
If I run in debug mode, application crashes and breaks at
ASSERT(IsWindow(pTemp->m_hWnd));
in the file occcont.cpp.
CreateDlgControls failed during dialog init. Detected memory leaks!
CoCreateInstance of OLE control {D27CDB6E-AE6D-11CF-96B8-444553540000} failed.
Result code: 0x80040154
Is the control is properly registered?
is displayed in the output window. Why it has happened suddenly(without no change in code)? Is this due to ServicePack? I 'm developing using Visual
Studio 2008 under Windows XP. The same project output runs fine at target systems. Here's the debug CallStack:
> mfc90ud.dll!COleControlContainer::FillListSitesOrWnds(_AFX_OCC_DIALOG_INFO * pOccDlgInfo=0x0012f7dc) Line 926 + 0x23
bytes
mfc90ud.dll!COccManager::CreateDlgControls(CWnd * pWndParent=0x0012fabc, const wchar_t * lpszResourceName=0x00000088,
_AFX_OCC_DIALOG_INFO * pOccDlgInfo=0x0012f7dc) Line 413
mfc90ud.dll!CDialog::HandleInitDialog(unsigned int __formal=853834, unsigned int __formal=853834) Line 661 + 0x1f bytes
mfc90ud.dll!CWnd::OnWndMsg(unsigned int message=272, unsigned int wParam=853834, long lParam=0, long * pResult=0x0012f49c)
Line 2018 + 0x11 bytes
mfc90ud.dll!CWnd::WindowProc(unsigned int message=272, unsigned int wParam=853834, long lParam=0) Line 1755 + 0x20 bytes
mfc90ud.dll!AfxCallWndProc(CWnd * pWnd=0x0012fabc, HWND__ * hWnd=0x000d074a, unsigned int nMsg=272, unsigned int
wParam=853834, long lParam=0) Line 240 + 0x1c bytes
mfc90ud.dll!AfxWndProc(HWND__ * hWnd=0x000d074a, unsigned int nMsg=272, unsigned int wParam=853834, long lParam=0) Line
403
mfc90ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000d074a, unsigned int nMsg=272, unsigned int wParam=853834, long lParam=0)
Line 441 + 0x15 bytes
user32.dll!7e418734()
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
user32.dll!7e418816()
user32.dll!7e42927b()
user32.dll!7e42651a()
user32.dll!7e42683e()
user32.dll!7e43f03a()
mfc90ud.dll!CWnd::CreateDlgIndirect(const DLGTEMPLATE * lpDialogTemplate=0x0016d820, CWnd * pParentWnd=0x00000000,
HINSTANCE__ * hInst=0x00400000) Line 312 + 0x2a bytes
mfc90ud.dll!CDialog::DoModal() Line 576 + 0x20 bytes
flash_mfc.exe!Cflash_mfcApp::InitInstance() Line 194 + 0xb bytes
mfc90ud.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, wchar_t *
lpCmdLine=0x00020846, int nCmdShow=1) Line 37 + 0xd bytes
flash_mfc.exe!wWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, wchar_t *
lpCmdLine=0x00020846, int nCmdShow=1) Line 34
flash_mfc.exe!__tmainCRTStartup() Line 578 + 0x35 bytes
flash_mfc.exe!wWinMainCRTStartup() Line 403
kernel32.dll!7c817077()
What to do to run the project at my system?
|
|
|
|
|