|
Just an idea! Can you have the WinForms dialogs in a COM compatible dll/class library? Then you might be able to use the WinForm dialogs in your unmanaged application. This might sound easier said then done but thought of just sharing the idea with you. You might also need to investigate on the feasiblity of this.
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
Is there any possibility to retrieve clicked menu item text?
In this example i can only get an ID, like:
unsigned in clicked = TrackPopupMenu(hContextMenu,
TPM_RETURNCMD |
TPM_VERPOSANIMATION,
rectangle.left+2, rectangle.bottom-2,
0,
hParent,
NULL);
So "clicked" contains ID now, like:
switch(clicked)
{
case MY_ID:
{
do_something();
}
}
I am interested in getting selected item text instead, because trying to implement dynamic popup menu. Lets say, there are some items in database, they could be changed, added, removed, and when i click a button - it should show a context menu with current items from DB (there are just about 10 items max).
Is there any "easy" way to do it? Or i am better off using combobox for that particular task?
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Well, once you have the ID of the menu item, you can use GetMenuItemInfo[^] to retrieve its text. However, since -as far as i understood- you fill the menu with the items yourself you have a way to know which ID represents which text, so you could also try e.g. putting the strings in an array and store their index in some way in the menu item ID, like, 1+index, and then when you got the ID from TrackPopup..., you subtract one and get the array index and don't need to fiddle around with GetMenuItemInfo.
p.s: in case you try the array thing, don't use 0 as a menu item ID (dunno if you can do that or not) because then you would not be able to distinguish between that menu item and the user dismissing the menu without a selection. That's why i suggested index+1...
> 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<
|
|
|
|
|
Great! Thanks. Here is the algo (my own classes but the algo is good):
case CATS_BUTTON:
{
ContextMenu *ctx = new ContextMenu();
wchar_t *err = NULL;
ctx->Create();
wchar_t **Cats = db->ListTables(DB_FILE, err);
int i;
for(i = 1; ; i++)
{
if(!IsNullOrEmpty(Cats[i - 1]))
{
ctx->AddItem(i, Cats[i - 1]);
}
else break;
}
unsigned int Clicked = ctx->TrackMenuHit2(hWnd,
Fbuttons[1]->operator HWND());
switch(Clicked)
{
case 0:
break;
default:
{
MessageBoxW(0,Cats[Clicked - 1],NULL,0);
}
break;
}
ctx->Destroy();
delete ctx;
}
break;
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Nicely done.
> 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<
|
|
|
|
|
Make it a habit not to use new/delete when you don't have to. You code will become simpler, potential resource leaks are eliminated, and you will be halfway to writing exception safe code.
|
|
|
|
|
i want to handle scrollbar properties in Cedit class like change width and color of scroll bar.
i use GetScrollBarCtrl function but it return null address. how can i change color and width.
|
|
|
|
|
|
Hi everyone . I try to use SetWindowLongPtr function to change behaviour of CComboBox control , but I get an error :
error C2065: 'SetWindowLongPtr' : undeclared identifier
what I can do ? I read somewhere that I need to install SDK , it's really necesary ? I mention that I use VC6 .
|
|
|
|
|
I think you will find that <a href="http://msdn.microsoft.com/en-us/library/ms633591(VS.85).aspx">SetWindowLong()</a>[<a href="http://msdn.microsoft.com/en-us/library/ms633591(VS.85).aspx" target="_blank" title="New Window">^</a>] should do what you want.
I must get a clever new signature for 2011.
|
|
|
|
|
I'd agree, although it's worth to mention that it's not supported for 64-bit versions of Windows.
After a bit of googling I found this[^] forum post, which seems to solve the problem.
Sadly, the download link to the feb 2003 platform SDK is broken, but maybe you can get it from somewhere else (I haven't tried).
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Thaddeus Jones wrote: it's not supported for 64-bit versions of Windows.
Something which is clearly explained if one reads through the documentation for both functions.
I must get a clever new signature for 2011.
|
|
|
|
|
mesajflaviu wrote: what I can do ?
Are you including the correct header file?
mesajflaviu wrote: I read somewhere that I need to install SDK , it's really necesary ?
Not for SetWindowsLong() , but it is highly recommended.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Actually it is indeed required to install the SDK in the case of Visual Studio 6, since it predates 64-bit versions of Windows and doesn't have SetWindowLongPtr without the SDK.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
I try
#include <Windows.h>
but didn't work.
|
|
|
|
|
Application A was using C.dll as an interface for camera. C.dll was and is erroneous. Sometimes it throws exceptions and causes the application to crash. Since the application is intended to be running always in the platform and is responsible for many things as well as handling cameras, we decided to use in indirect method for the application to use the camera. The plan was to separate the dll from the application. Another application got responsible for getting involved with sending the appropriate commands to the camera via the dll and in another side be in communication with the application. We call it server. The application is now a client for it. The communication between these two separate processes is established via a named pipe. I've tested this link and it works fine.
Now the problem is that after starting the camera I use the following code to capture an image:
bool CCamera::CaptureImage(LPCSTR i_lpszBMPFileName)
{
if (m_hWnd &&
capGrabFrameNoStop(m_hWnd) &&
capFileSaveDIB(m_hWnd, i_lpszBMPFileName))
return true;
return false;
}
The m_hWnd is created with this code:
m_hWnd = capCreateCaptureWindow(m_sName, WS_CHILD|WS_CLIPSIBLINGS, 0, 0, 160, 120, i_hwndParnt, 0xffff);
i_hwndParent in both cases (before separating the application and after it) is obtained with the following code:
i_hwndParent = CreateWindow("STATIC", "parent", WS_POPUP, 0, 0, 20, 10, NULL, NULL, NULL, NULL);
Before changing the method to a client/server method, in CaptureImage everything was working fine. Both capxxx macros did their job and returned with true or false. But now, the program control remains inside them and the if statement is not evaluated until I stop the camera. After stopping the camera these macros return with true. It causes the application to remain in the CaptureImage function and never returns until the camera is stopped. I wondered what might be different in two methods. I couldn't realize why the macros don't return.
Any idea?
Thx
|
|
|
|
|
This is really for those Visual C++ 6.0 programmers out there.
I have a workspace which builds 3 apps & dozen of DLLs. Each project has it's own resources (resource.h & corresponding RC file).
I like to merge the resources of the 3 main apps into one. I notice the 3 apps share some common strings. However, due to 10-20 years of development, the defined constants that have same name may not have same number.
App1 resource.h
#define IDS_STRING1 82
App2 resource.h
#define IDS_STRING1 79
App3 resource.h
#define IDS_STRING1 83
Am wondering if there's a tool out there that can clean up multiple resources... to make final/eventual merging easier.
Problems lie when it's a common define constant, but the string literal are actually different.
So maybe should have a batch routine to index/map by the string literal first, then ensure the define constant matches, if not then flag it.
My resource.h files are huge, millions of lines... hence why am wondering if there exists a resource.h cleaner.
|
|
|
|
|
|
Why would you want to combine resources? I find it easier and cleaner to have the separation...
|
|
|
|
|
Hi Experts,
How to write a plugin(firefox) for an activex control. please give me some clues regarding this. I have searched many times but didn't got a proper way...
Regards,
Spk521
|
|
|
|
|
|
hi,
i did not got your answer.
My question is that suppose my screen resolution is 1024x768 and i have designed my GUI as per the current resolution.
by using following code i can get my systems current resolution
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
MessageBox::Show("Screen Resolution is : " +monitor_width +" x " + monitor_height, "Dnyan", MessageBoxButtons::OK, MessageBoxIcon::Information);
double xRatio = monitor_height / 800.00;
double yRatio = monitor_width / 600.00;
}
public: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
monitor_height=Screen::PrimaryScreen->Bounds.Height;
monitor_width=Screen::PrimaryScreen->Bounds.Width;
}
Now suppose my project is in network and one persons system resolution is 800x600 second person screen resolution is 1024x768 and others is different
in this case i want to adjust control default location as well as its size as per screen resolution
then please tel me how its possible in C++ with Windows platform (in .net IDE)
Please help me
|
|
|
|
|
Please re-post your question in appropriate forum.
I believe in LOVE AT FIRST SIGHT...
Bcoz I have loved my Mother...
even since I opened my eyes...(ICAN)
|
|
|
|
|
This question has already been responded to here[^]. Please do not start a new thread for an existing question.
I must get a clever new signature for 2011.
|
|
|
|
|
I had the same problem. You design your GUI for the lowest resolution (as someone already suggested), then when you're at a higher resolution, you have extra space in the X and Y directions. You then write functions to 1) space the controls (vertically and horizontally) using this extra space, and 2) enlarge the controls with the extra space.
Not all controls will use extra space, e.g. buttons will remain the same size. But list boxes can use the extra space to show more data.
You can write one class that does all this, then call it with each of your forms, the extra X and Y space, and resizing information.
For the resizing information, I defined a language called WASP (Window Arrangement Specification Protocol) with statements consisting of ints. The first int is the operation (e.g. space in X direction, add N percent of the X extra apace to the following controls, etc).
I did this in MFC, and each control was referred to by its int ID. Sizes and percents were also ints. Since a WASP program is all ints, I could define it as a static array of ints in my program. The advantage to this is that I didn't have to deal with any parsing or lexical analysis; I just passed the int-array WASP program to the WASP class. I used #defines for the int operations for readability.
There's a separate WASP program for each form you want to resize. The WASP program is run once when your form is initialized.
|
|
|
|