How to make these boxes?

I don’t know how exactly to call what I want to implement. It’s like a box surrounded with a line and, depending on the context, I want to place a graphic on the right corner e.g. a light bulb or a question mark.

I want to place these boxes in more than one place, so if there’s a link explaining how to automate these things – a macro I guess – that would be appreciated too.

enter image description here

Solutions Collecting From Web of "How to make these boxes?"

Update

After new requirement in comments, now theres just one environment coolbox with a mandatory argument (the file image to be used) and two optional ones:

\begin{coolbox}[<options for the box>]{<image-file>}[<options for the image>]
(contents)
\end{coolbox}

The code:

\documentclass[12pt]{article}
\usepackage[many]{tcolorbox}
\usepackage{graphicx}

\definecolor{boxbg}{RGB}{179,222,255}

\tcbset{
  common/.style={
    before=\vskip2\baselineskip\noindent,
    after=\vskip2\baselineskip,
    enhanced,
    frame code={},
    fontupper=\LARGE,
    fontlower=\LARGE,
    segmentation empty,
    middle=0.7cm,
    top=0.5cm
  }
}

\DeclareTColorBox{coolbox}{O{}mO{}}{
common,
interior code={
  \filldraw[ultra thick,densely dashed,fill=boxbg,draw=black,rounded corners=10pt,#1] (interior.north west) rectangle (interior.south east);
  \node at  ([xshift=-30pt,yshift=5pt]interior.north east) {\includegraphics[#3]{#2}};
  },
}

\begin{document}

\begin{coolbox}{lightbulb}[height=2cm]
Did you know:
\tcblower
Once upon a time there was a latch \\
that wanted to be a flip-flop?
\end{coolbox}

\begin{coolbox}{questionmark}[width=1cm,angle=-20]
Did you know:
\tcblower
Once upon a time there was a latch \\
that wanted to be a flip-flop?
\end{coolbox}

\begin{coolbox}[fill=red!20,draw=red]{exclamationmark}[width=1.5cm,angle=-20]
Did you know that adding some more text
\tcblower
Once upon a time there was a latch \\
that wanted to be a flip-flop?
\end{coolbox}

\end{document}

enter image description here

Using tcolorbox; adjust the settings according to your needs:

enter image description here

The code:

\documentclass[12pt]{article}
\usepackage[many]{tcolorbox}
\usepackage{graphicx}

\definecolor{boxbg}{RGB}{179,222,255}

\tcbset{
  common/.style={
    before=\vskip2\baselineskip\noindent,
    after=\vskip2\baselineskip,
    enhanced,
    colback=boxbg,
    frame code={},
    fontupper=\LARGE,
  }
}

\newtcolorbox{ideabox}{
common,
interior code={
  \filldraw[ultra thick,densely dashed,fill=boxbg,draw=black,rounded corners=10pt] (interior.north west) rectangle (interior.south east);
  \node at  ([xshift=-30pt,yshift=5pt]interior.north east) {\includegraphics[width=2.5cm]{lightbulb}};
  }
}
\newtcolorbox{questionbox}{
common,
interior code={
  \filldraw[ultra thick,densely dashed,fill=boxbg,draw=black,rounded corners=10pt] (interior.north west) rectangle (interior.south east);
  \node at  ([xshift=-30pt,yshift=5pt]interior.north east) {\includegraphics[width=1.5cm,angle=-30]{questionmark}};
  }
}

\begin{document}

\begin{ideabox}
Did you know:\par\vskip1cm

Once upon a time there was a latch \\
that wanted to be a flip-flop?
\end{ideabox}

\begin{questionbox}
Did you know:\par\vskip1cm

Once upon a time there was a latch \\
that wanted to be a flip-flop?
\end{questionbox}

\end{document}

If all the boxes are going to have this structure (i.e., an upper and a lower part), then (as cmhughes suggests in his comment) one can use \tcblower and middle to avoid manually producing the vertical separation:

\documentclass[12pt]{article}
\usepackage[many]{tcolorbox}
\usepackage{graphicx}

\definecolor{boxbg}{RGB}{179,222,255}

\tcbset{
  common/.style={
    before=\vskip2\baselineskip\noindent,
    after=\vskip2\baselineskip,
    enhanced,
    colback=boxbg,
    frame code={},
    fontupper=\LARGE,
    fontlower=\LARGE,
    segmentation empty,
    middle=0.7cm
  }
}

\newtcolorbox{ideabox}{
common,
interior code={
  \filldraw[ultra thick,densely dashed,fill=boxbg,draw=black,rounded corners=10pt] (interior.north west) rectangle (interior.south east);
  \node at  ([xshift=-30pt,yshift=5pt]interior.north east) {\includegraphics[width=2.5cm]{lightbulb}};
  }
}
\newtcolorbox{questionbox}{
common,
interior code={
  \filldraw[ultra thick,densely dashed,fill=boxbg,draw=black,rounded corners=10pt] (interior.north west) rectangle (interior.south east);
  \node at  ([xshift=-30pt,yshift=5pt]interior.north east) {\includegraphics[width=1.5cm,angle=-30]{questionmark}};
  }
}

\begin{document}

\begin{ideabox}
Did you know:
\tcblower
Once upon a time there was a latch \\
that wanted to be a flip-flop?
\end{ideabox}

\begin{questionbox}
Did you know:
\tcblower
Once upon a time there was a latch \\
that wanted to be a flip-flop?
\end{questionbox}

\end{document}

enter image description here

enter image description here

\documentclass[border=2pt]{standalone}
\usepackage{tikz,xcolor}                   
\usetikzlibrary{calc}
\definecolor{skyblue}{HTML}{B9E1FD}

\begin{document}

\begin{tikzpicture}[line width=.7pt, inner sep=7pt]
  \node [draw,rounded corners,dashed,fill=skyblue,text width=.6\textwidth] (B){%
  \bfseries Did you know? \par \bigskip  
  Once upon a time there was a latch that wanted to be a flip.flop};
  \node [rotate=-30]at($(B.north)!.65!(B.north east)$) {\includegraphics[scale=.09]{bulb}};
\end{tikzpicture}

\end{document} 

TikZ can also be used to produce such fancy boxes. The width can be adjusted as required (I used .65\textwidth here). Also the color is your choice (I used {HTML}{B9E1FD} here).

Finally, the lightbulb image can be downloaded from this site.

enter image description here

Now the question block is obtained the same way as above with the last line changed to:

\node at ($(B.north)!.72!(B.north east)$) {\includegraphics{quest}};

Again, the question mark image was obtained from here.