Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have multiple static controls, defined with the SS_NOTIFY style.
How can I discern which control was clicked when I am handling the message with STN_CLICKED?
The documentation tells you:
lParam: Handle to the static control.
The lParam has the HWND of the static control that is sending the notification.
you need assign unique ID to every control. and you got this id back inside wParam when you handle STN_CLICKED notification
for example
switch (uMsg)
{
case WM_COMMAND:
switch (wParam)
{
case MAKEWPARAM(IDC_STATIC_1, STN_CLICKED ):
do_something_1();
break;
case MAKEWPARAM(IDC_STATIC_2, STN_CLICKED ):
do_something_2();
break;
}
break;
}
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 days ago.
Improve this question
Image showing error in vs code
I am following a tutorial video ,in which when he is using "string" as data type it is not showing any error
but when i am using it it shows an error . but when iam using "Var" instead of string the error would go away.
Its because of null safety as var is nullable so you need not to initialize but inacase of string it is not nullable so you need to make it like this
class Deck {
List<Card> cards = [];
}
class Card {
String? suit;
String? rank;
}
//to access use this
void test()
{
Card c = Card();
print(c.suit ?? "unknown suit");
print(c.rank ?? "unknown rank");
}
or alternatively better make a constructor
class Card2{
String suit;
String rank;
Card2(this.suit, this.rank);
}
//use like this
void test2()
{
Card2 c2 = Card2("suit", "9.8");
print(c2.suit);
print(c2.rank);
}
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
There is a recommended way where put receivers in Go when we have multiple structs in one file?
Option A: Methods after each struct
Buyer struct {
// omitted code
}
func (s *Buyer) Buy() {
// omitted code
}
Seller struct {
// omitted code
}
func (s *Seller) Sell() {
// omitted code
}
Option B: Methods after all structs
Buyer struct {
// omitted code
}
Seller struct {
// omitted code
}
func (s *Buyer) Buy() {
// omitted code
}
func (s *Seller) Sell() {
// omitted code
}
The language spec allows you to put them anywhere in the same package (you can put them in different files too but must be in the same package). Spec: Method declarations:
A receiver base type cannot be a pointer or interface type and it must be defined in the same package as the method.
Other than that it's just common sense. Put them close (next) to the receiver type (which is Option A in your question). Easier to find, easier to maintain.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Im calling this funcion in many tests. How can i put that in commands.js file and call it where needed
Following Cypress guide. Cypress recommendation is to use commands.js
Documentation link :
[https://docs.cypress.io/api/cypress-api/custom-commands.html#Syntax][1]
You can add CategoryNumber() like this. Go to Support Folder. You will see Command.js
Cypress.Command.add('CategoryNumber, ()=> {
ACTUAL FUNCTION Code
}
How to call?
Go to test definition and call as cy.CategoryNumber()
example function :
Cypress.Commands.overwrite('visit', (originalFn, url, options) => {
const domain = Cypress.env('BASE_DOMAIN')
if (domain === '...') {
url = '...' }
if (options.something === 'else') {
url = '...' }
// originalFn is the existing visit command that you need to call
// and it will receive whatever you pass in here. // // make sure
to add a return here! return originalFn(url, options)
})
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I dont Know how to set the border color . if the user enter the wrong keyword then the border shows red color on it. let me know if anyone have this solution for this. I have attached sample image here. Thanks!
sample screenshot
i need exactly same like this.
You can check on button click event using regular expression for Password field and match your both text are same or not.
Code :
public void btnclick(object sender, EventArgs args)
{
if(string.ISNullOrEmpty(entrypassword.text))
{
lblerror1.text = "Password Required";
return;
}
if(string.ISNullOrEmpty(entryconfirmpassword.text))
{
lblerror2.Text = "Confirm Password required";
return;
}
else
{
if(entrypassword.text.length <9)
{
lblerror1.Text = "Password must be 8 characters";
return;
}
if(entrypassword.text != entryconfirmpassword.text)
{
lblerror2.Text = "Passwords are not match";
return;
}
else
{
// your button click code
}
}
}
There is also second option is Triggers of Entry.
I'm doing some small changes to C++ MFC project. I'm .NET developer so Windows programming is new to me.
I need to launch some method right after CDialog is completely shown (painted) for the first time, but only once.
How can I do this? In .NET I would handle Form.Shown event.
Do I need to handle some message? Which?
Do I need to override some CDialog method?
Or is there no easy way? I'm thinking of handling WM_ACTIVATE and then using a flag to ensure I call another method only once.
Found the answer here: Waiting until the dialog box is displayed before doing something
Short story:
INT_PTR CALLBACK
DlgProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
switch (uiMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_WINDOWPOSCHANGED:
if ((((WINDOWPOS*)lParam)->flags & SWP_SHOWWINDOW) &&
!g_fShown) {
g_fShown = TRUE;
PostMessage(hwnd, WM_APP, 0, 0);
}
break;
case WM_APP:
MessageBox(hwnd,
IsWindowVisible(hwnd) ? TEXT("Visible")
: TEXT("Not Visible"),
TEXT("Title"), MB_OK);
break;
case WM_CLOSE:
EndDialog(hwnd, 0);
break;
}
return FALSE;
}
If you're using MFC like I am you'll need to map WM_WINDOWPOSCHANGED and then use ON_MESSAGE to map WM_APP. See this CodeProject article for more details.
For reference you don't need to override DlgProc to intercept WM_WINDOWPOSCHANGED.
ON_WM_WINDOWPOSCHANGED()
ON_MESSAGE(MyCDialog::MY_USER_MSG, OnDialogShown)
void MyCDialog::OnWindowPosChanged(WINDOWPOS *wndpos)
{
__super::OnWindowPosChanged(wndpos);
if (!mDialogShown && (wndpos->flags & SWP_SHOWWINDOW)) {
PostMessage(MY_USER_MSG);
mDialogShown = true;
}
}
LRESULT MyCDialog::OnDialogShown(WPARAM, LPARAM)
{
...
}
You can implement the handling inline instead of posting another message if appropriate.
Another approach I've used a number of times with great success is to use a timer. Set it for 10m0s. It'll only fire after the dialog is shown.
Hell put the code in OnPaint() and thow a bool m_fullyInitilized in your class.
I like the timer too.. Though I usually go with 100ms. I also move all my initilization code out of the oninit, in these cases.. Just to protect against too much processing in there.