How to set and disable check boxes in C++ using visual studio?

Hi. I am attempting to make a GUI program as a personal project in C++ using visual studio. This is what the program does: If you run the program at 2:30pm, the program will check off a box that says "you are in hour two" (because the hour of the day in which you decide to run the program is in the 2th hour). If you run the program at 7:20am, the program will check off a box that says "you are in hour 7" (because the hour of the day in which you decide to run the program is in the 7th hour). Lastly, it has a label at the top of the window will show the current local time.

I know need to make 12 check boxes to represent each hour of the day. I also need to disable the check boxes so that the user can not change the check boxes. Also, the computer needs to check off the box based off of the local time. Lastly, I want a button that will refresh the check boxes based off of the new time and refreshes the label that shows the current local time(ex: If the user opens the app at 8:00pm the check box that says "you are in hour 8" will be checked off. If the user leaves the GUI program on for an hour, the refresh button should check off "you are in hour 9" because by then it will be 9:00pm. Then it should change the label to the new local time).

I don't know some of the syntax in C++ to do set and disable the check buttons. If anyone knows the how to do this, I will greatly appreciate the help.

Here is my code so far:

public:
        MyForm(void)
        {
            InitializeComponent();

            //Shows current time in label 2
            DateTime datetime = DateTime::Now;
            this->label2->Text = datetime.ToString("hh:mm");

            checkBox1->Enabled = false; //disables checkbox for hour 1
            checkBox2->Enabled = false; //disables checkbox for hour 2
            checkBox3->Enabled = false; //disables checkbox for hour 3
            checkBox4->Enabled = false; //disables checkbox for hour 4
            checkBox5->Enabled = false; //disables checkbox for hour 5
            checkBox6->Enabled = false; //disables checkbox for hour 6
            checkBox7->Enabled = false; //disables checkbox for hour 7                          
            checkBox8->Enabled = false; //disables checkbox for hour 8
            checkBox9->Enabled = false; //disables checkbox for hour 9
            checkBox10->Enabled = false; //disables checkbox for hour 10
            checkBox11->Enabled = false;//disables checkbox for hour 11
            checkBox12->Enabled = false; //disables checkbox for hour 12
            //
            //TODO: Add the constructor code here
            //
        }
//_______________________________________________________________
/*Here is what I have done for hour 1. If I can get this to work then I can do the same for the other check boxes.*/

private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
    //Controls time for binary clock
    time_t currentTime;
    struct tm* localTime;

    time(&tTime);                   // Get the current time
    localTime = localtime(&tTime);  // Convert the current time to the local time

    int Hour = localTime->tm_hour % 12; //Must mod time by 12 to get standard time

    if (Hour = 1) {

        checkBox1->Checked = true; //checks off box
    }
}
//__________________________________________________________
/*This part of the code is for the refresh button. Right now, all it does is updates
the current time in label 2 but does not update the check boxes to reflect the time*/

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
    DateTime datetime = DateTime::Now;
    this->label2->Text = datetime.ToString("hh:mm");
}

Two Lessons I Learned From Making React Components

Here’s a couple of lessons I’ve learned about how not to build React components. These are things I've come across over the past couple of months and thought they might be of interest to you if you’re working on a design system, especially one with a bunch of legacy technical decisions and a lot of tech debt under the hood.

Lesson 1: Avoid child components as much as you can

One thing about working on a big design system with lots of components is that the following pattern eventually starts to become problematic real quick:

<Card>
  <Card.Header>Title</Card.Header>
  <Card.Body><p>This is some content</p></Card.Body>
</Card>

The problematic parts are those child components, Card.Body and Card.Header. This example isn't terrible because things are relatively simple — it’s when components get more complex that things can get bonkers. For example, each child component can have a whole series of complex props that interfere with the others.

One of my biggest pain points is with our Form components. Take this:

<Form>
  <Input />
  <Form.Actions>
    <Button>Submit</Button>
    <Button>Cancel</Button>
  </Form.Actions>
</Form>

I’m simplifying things considerably, of course, but every time an engineer wants to place two buttons next to each other, they’d import Form.Actions, even if there wasn’t a Form on the page. This meant that everything inside the Form component gets imported and that’s ultimately bad for performance. It just so happens to be bad system design implementation as well.

This also makes things extra difficult when documenting components because now you’ll have to ensure that each of these child components are documented too.

So instead of making Form.Actions a child component, we should’ve made it a brand new component, simply: FormActions (or perhaps something with a better name like ButtonGroup). That way, we don’t have to import Form all the time and we can keep layout-based components separate from the others.

I’ve learned my lesson. From here on out I’ll be avoiding child components altogether where I can.

Lesson 2: Make sure your props don’t conflict with one another

Mandy Michael wrote a great piece about how props can bump into one another and cause all sorts of confusing conflicts, like this TypeScript example:

interface Props {
  hideMedia?: boolean
  mediaIsEdgeToEdge?: boolean
  mediaFullHeight?: boolean
  videoInline?: boolean
}

Mandy writes:

The purpose of these props are to change the way the image or video is rendered within the card or if the media is rendered at all. The problem with defining them separately is that you end up with a number of flags which toggle component features, many of which are mutually exclusive. For example, you can’t have an image that fills the margins if it’s also hidden.

This was definitely a problem for a lot of the components we inherited in my team's design systems. There were a bunch of components where boolean props would make a component behave in all sorts of odd and unexpected ways. We even had all sorts of bugs pop up in our Card component during development because the engineers wouldn’t know which props to turn on and turn off for any given effect!

Mandy offers the following solution:

type MediaMode = 'hidden'| 'edgeToEdge' | 'fullHeight'

interface Props {
  mediaMode: 'hidden'| 'edgeToEdge' | 'fullHeight'
}

In short: if we combine all of these nascent options together then we have a much cleaner API that’s easily extendable and is less likely to cause confusion in the future.


That’s it! I just wanted to make a quick note about those two lessons. Here’s my question for you: What have you learned when it comes to making components or working on design systems?

The post Two Lessons I Learned From Making React Components appeared first on CSS-Tricks.

Print-Inspired Layout on the Web

I always love seeing people get inspired by print design and trying to port it over to the web. There is a much deeper history of interesting print work to draw from, and still a ton of modern work happening that eclipses most digital design work today. The web is fully capable of bold, interesting designs, yet we see it all-too-rarely.

Just lately, we've seen a little surge of interest...

Dan Davies took inspiration from nine different print articles and built layouts that are similar in spirit to each of them.


Ahmad Shadeed rebuilt a rather complex grid layout with bold typography inspired by an image from a book.


Facundo Corradini built out a design from The New York Times Style Magazine.


Frederick O’Brien compared newspaper design to web design.

Continue reading "Print-Inspired Layout on the Web"

I have a problem with the last text.It dosen’t appere

This is my code.

#include "pch.h"
#include <iostream>
#include <Windows.h> 
#include <string>
#include <ctime>
#include <fstream>

using namespace std;

std::string AppName = "League of Legends";
LPCSTR LAppWindow = "Riot Client";
std::string AppStatus;

bool IsAppAvil;
bool Update;

int main()
{
    //Start App
    ShellExecuteA(NULL,"open","D:\\Games\\Riot Games\\League of Legends\\LeagueClient.exe\\",NULL,NULL, SW_SHOWDEFAULT);

    //Checking if app is running
    HWND hGameWindow = NULL;
    int timeSinceLAstUpdate = clock();
    int AppAvailTMR = clock();
    int onePressTMR = clock();
    int Timer = 0;
    DWORD dwProcID = NULL;
    HANDLE hProcHandle = NULL;

    while(!GetAsyncKeyState(VK_ESCAPE))
    {
        Timer += 1;
        if (clock() - AppAvailTMR > 100)
        {
            AppAvailTMR = clock();
            IsAppAvil = false;

            hGameWindow = FindWindowA(NULL, LAppWindow);

            if (hGameWindow)
            {
                GetWindowThreadProcessId(hGameWindow, &dwProcID);
                if (dwProcID != 0)
                {
                    hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcID);
                    if (hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
                    {
                        AppStatus = "Faild to open.Invalid HANDLE";
                    }
                    else
                    {
                        AppStatus = "App opend";
                        IsAppAvil = true;
                    }
                }
                else
                {
                    AppStatus = "Faild to open.Didn't get the process ID";
                }
            }
            else
            {
                AppStatus = "Faild to open.App not found";
            }
        }

            Sleep(1000);
            system("cls");
            cout << "-------------------------------------------------------------------" << endl;
            cout << "                      Auto App Loger" << endl;
            cout << "-------------------------------------------------------------------" << endl;
            cout << "APP STATUS: " << AppStatus << endl;
            cout << "[ESC] exit" <<endl;

    }

    return ERROR_SUCCESS;
}

void ReadTxt() 
{
    std::string line_;
    ifstream file_("Nam.Password.txt");
    if (file_.is_open())
    {
        std::cout << "Reading file" << '\n' << endl;
        while (getline(file_, line_))
        {
            std::cout << line_ << '\n' << endl;
        }
    }
    else
    {
        std::cout << "File not found" << '\n' << endl;
    }
}

One-Time vs. Recurring Payments for WordPress Products

Jeff Starr posed the question at Digging into WordPress: Which Pricing Model Do You Prefer: One-Time or Recurring?

It is not the first time the question has been asked in the WordPress community and will not be the last. It is important that we keep coming back to it from time to time.

In the early days of the commercial WordPress ecosystem, many shops sold products for a one-time fee. This was particularly true during the 2007-2010 years, which were what many dub the “WordPress themes heyday,” a period in which theme shops raked in tons of cash due to lack of competition.

As the market became more saturated, many businesses saw the writing on the wall. One-time fees for commercial themes or plugins did not make for a sustainable business model. Of course, some companies pushed forward with that model. They were either large enough to capitalize on an influx of new customers every year or they continued to push out new products for existing customers to buy.

Today, most theme and plugin shops utilize a recurring business model. Many of those shops also set up automatic renewals. From a business perspective, companies need to keep existing customers while bringing in new buyers to continue maintaining, supporting, and building new features for the current product catalog. Companies also need growth to build new products. A recurring fee helps ease the burden of supporting and maintaining the existing products.

Pippin Williamson saw massive revenue growth over 20 months after turning on automatic renewals across his company’s various products. Other companies have seen similar increases with the same model.

As a former business owner, I dumb-lucked my way into yearly, recurring payments. When I first launched a theme shop in 2008, that was the model I went with. I did not know a single thing about running a business except that money exchanged hands. I was in my early 20s and accustomed to living off minimum wage, digging change from the couch to buy a value meal, and finding creative ways — short of dumpster diving — to scrape by. Anything better than that was a success for me. Recurring payments just made sense, especially because I was vastly undercutting my competitors in price. That one decision helped sustain my business for many years. In hindsight, I would not have had the little success I had with a single-payment model because I never brought in enough new customers.

Having worked on the business end of WordPress for over a decade and being a member of the community for even longer, it is easy for me to say most companies should use a recurring business model.

However, as a software customer in general, I have not always maintained that mindset. There are many pieces of software that I loathe paying for each year. This was particularly true before running a business that dealt with software. There is a part of me that feels some shame for disliking the recurring model with non-WordPress software. Those businesses need to pay their employees and afford to continue making the product better.

On the other hand, there is always that part of me that simply wants to pay for something once and always have access to it. Perhaps I am a product of my culture. Software is unlike other art forms where Version 1.0 is the finished product. Customers do not always see the work that goes on to maintain, support, and continue building a product. That is certainly true when I look at non-WordPress software.

For WordPress products, I am always more than happy to pay a recurring fee because I have been on the other side. I also get to talk with others every day who are trying to run their own companies. That human variable in the equation changes how I view software in the WordPress ecosystem in a way that is much harder with other software.

A Middle Ground

Starr pointed out a middle-of-the-road option that few WordPress companies take but is often the model used for other software products. Major releases of software carry an upgrade fee while minor and patch releases are included with the initial purchase. Often, major software releases have years in between. Customers may not feel like they are constantly having to pay for updates in this system. Major upgrades also mean feature upgrades. Features are what sell the product to the average end-user.

Scrivener, a writing program for authors, uses this model. Instead of having to pay yearly, I can upgrade to the new, shiny version when it drops with loads of features. As a customer, I feel like I am getting something tangible when forking over the cash for an update.

Perhaps I am happy to continue paying for software that helps me pursue my lifelong dream of becoming a novelist. Perhaps the company simply knows how to sell to its customer base. Either way, it is one piece of software that I have never complained about renewing.

What is the Best Option?

To answer the question posed by Starr, I will always prefer a one-time fee as a customer simply because it is in my nature to want to pay the least amount I can for anything. However, I would prefer most WordPress businesses to go with whatever model is most sustainable for their specific business. We are all in this boat together, and I wish growth for the ecosystem.

One of the missing pieces with many WordPress plugin and theme shops is that they need to find creative ways to sell the customer on coming back. Support and maintenance can be eye-catching for agencies and freelancers, but they are not always selling points for the average consumer after that initial purchase.

Right now, there is a sense of complacency as WordPress-related businesses have stuck with similar recurring options over the last several years. It might be time for someone to shake things up.

Making Data Scientists Productive in Azure

Doing data science today is far more difficult than it will be in the next 5 to 10 years. Sharing and collaborating on workflows in painful, pushing models into production is challenging. Let’s explore what Azure provides to ease data scientists’ pains.

In this post, you will learn about the Azure Machine Learning Studio, Azure Machine Learning, Azure Databricks, Data Science Virtual Machine, and Cognitive Services. What tools and services can we choose based on a problem definition, skillset, or infrastructure requirements?

Authorization Approach for Multiple Web API Providers

Azure Active Directory (Azure AD) is a popular enterprise identity service used by many organizations for enabling single sign-on for applications and protect their web APIs.

Version 2.0 of Microsoft Identity platform (aka Azure AD) is the latest and improved implementation of OpenId Connect (OIDC) based authentication and OAuth 2.0 authorization flows.

A Few Notes From a Year of Freelancing

Recently I wrote an article about how I prepared to join the world of freelancing. Now that I’m over a year into freelancing and loving life, I thought it would be beneficial to share with you what I’ve learned so far. 

1. Set Your Rate

Time is money, and as a freelancer, you have to be very specific as to what exactly an hour of your time is worth. This varies depending on the type of software you write and the amount of experience you have. I suggest that you research your direct competitors in the area and find out how much they charge. Initially, you probably want to charge a bit less until you have a considerable amount of projects under your belt and numerous references from happy customers. 

Global gitignore [Code Snippet]

Let's learn more about global gitignore, a widely used Git feature that allows files to be ignored within the Git repository.

Global gitignore

A widely used Git feature is to use local .gitignore files which list which names and patterns of files and directories will be ignored within the Git repository.

REST-API Versioning Strategies

REST-API Versioning Strategies

Abstract

The approach to managing Application Programming Interfaces (APIs) for distributed heterogeneous systems differs from the classic tools as offered by Apache Maven, which is designed to simplify build processes for the assembly of technologically and homogeneously similar artifacts. The limitations of such a classic dependency management tool become evident in the context of managing APIs between technologically different and independent systems, where APIs such as the Representational State Transfer (REST-APIs) ensures their networking capabilities, for instance.

The mutual contract between a service provider, which might offer a few API versions implemented, and its consumers, plays a critical role and thus demands another approach to guarantee the contract by design in operation for a prolonged period. Moreover, the semantic versioning as used by Apache Maven by differentiating three digits would be unrealistic for REST-APIs.

The Making of a “Special Series” on a WordPress Site

We just ran a fancy article series here on CSS-Tricks with a bunch of different articles all answering the same question. By fancy, I mean two things:

  • The articles had a specially-designed template just for them. (Example)
  • The series has a specially-designed landing page.

One of the reasons I enjoy working with WordPress is because of how easy this is to pull off. I'm sure any CMS has their own ways of doing this, and I don't mean it to be a battle-of-CMSs thing here. I just want to illustrate how easy I found this to pull off in WordPress.

Any post can have a template

I made a PHP file in the theme directory called eoy-2019.php (eoy meaning "End of Year," the spirit of this series). At the top of this file is some special code comments to make it read as a template:

<?php
/*
Template Name: EOY 2019
Template Post Type: post
*/

Now any post we publish can select this template from a dropdown:

And they'll use our cool template now!

Special scripts and styles for that template

I actually didn't need any scripting for this, but it's the same concept as styles.

I put a conditional check in my header.php file that would load up a CSS file I created just for these posts.

if (is_page_template('art-direction/eoy-2019.php') || is_category('2019-end-of-year-thoughts')) {
  wp_enqueue_style('eoy-2019', get_template_directory_uri() . "/css/eoy-2019.css?version=7");
}

A special template for the whole group

I could have grouped the posts together in any number of ways:

  • I could have made a special Page template for these posts and designed that to link to these special posts manually or with a custom query/loop.
  • I could have had them share a tag, and then created a special tag archive page for them.
  • I could have used the same system we used for our Guides, which is a combination of CMB2 and the attached-posts plugin.

Instead, I gave all the posts the same category. That felt the most right for whatever reason. We don't use categories a ton, but we use them for some major groups of posts, like Chronicle posts.

By using a category, I can use a special templating trick. Naming the file category-2019-end-of-year-thoughts.php, I can use the end of that file name to match the slug of the category name I used and it "just works," thanks to the WordPress template hierarchy. I don't need to write any code for that file to be used to display this category and I get the URL for free. Now I have a file I can use to build a special design just for these posts.

Future fallbacks

Let's say it's five years from now and I've kinda stopped caring about the super special styling and treatment behind these posts. I don't know if that will happen, but it might. All these special files can just be deleted without hurting the content or URLs.

Again, thanks to the template hierarchy, the special post templates will simply fall back to the regular single.php template. The category homepage will just render from the regular archive.php template. The special styles won't be applied, but the content will be just fine and the URLs will be unchanged. Nice.

The post The Making of a “Special Series” on a WordPress Site appeared first on CSS-Tricks.

css.gg

I'm not sure what to call these icons from Astrit Malsija. The title is "500+ CSS Icons, Customizable, Retina Ready & API" and the URL is "css.gg" but they aren't really named anything.

Anyway, their shtick is:

The 🌎's first icon library designed by code.

The idea is that they don't use clip-path, they aren't icon fonts, they aren't even SVG. They are just <i> tags essentially using the shapes of CSS and pseudo elements as necessary to draw themselves. It's a very clever approach. They'll render super fast, like inline SVG would, because they don't require any other resource. They don't scale particularly well because everything is sized in px, but they have modifier classes for a handful of predefined sizes. I probably wouldn't use these in production (inline SVG is the way to go), but still, it's clever.

I wouldn't call it the world's first either. Nicolas Gallagher designed an icon set like this 10 years ago (!).

Direct Link to ArticlePermalink

The post css.gg appeared first on CSS-Tricks.

honestly can you help me converting this c++ code to Python3 code?

    MyMainWindow::createUI()
    {
        label = new QLabel("foo");
        button = new QPushButton("Browse");
        connect(button, SIGNAL(clicked()), SLOT(browse()));
        layout = new QHorizontalLayout();
        layout->addWidget(label);
        layout->addWidget(button);
        setLayout(layout);
    }

    void MyMainWindow::browse()
    {
        QString directory = QFileDialog::getExistingDirectory(this,
                                tr("Find Files"), QDir::currentPath());

        if (!directory.isEmpty()) {
            if (directoryComboBox->findText(directory) == -1)
                directoryComboBox->addItem(directory);
            directoryComboBox->setCurrentIndex(directoryComboBox->findText(directory));
        }
    }

MyMainWindow::createUI()
{
    label = new QLabel("foo");
    button = new QPushButton("Browse");
    connect(button, SIGNAL(clicked()), SLOT(browse()));
    layout = new QHorizontalLayout();
    layout->addWidget(label);
    layout->addWidget(button);
    setLayout(layout);
}

void MyMainWindow::browse()
{
    QString directory = QFileDialog::getExistingDirectory(this,
                            tr("Find Files"), QDir::currentPath());

    if (!directory.isEmpty()) {
        if (directoryComboBox->findText(directory) == -1)
            directoryComboBox->addItem(directory);
        directoryComboBox->setCurrentIndex(directoryComboBox->findText(directory));
    }
}